From 7b722205f42b9ed8562b3339a1940c49c72e2457 Mon Sep 17 00:00:00 2001
From: David Brown <dbrown@gitlab.riscosopen.org>
Date: Mon, 29 Sep 1997 11:10:02 +0000
Subject: [PATCH] Altered hotlist_add to create the new url after the first
 selected item or inside the first selected directory when an item is
 selected.

---
 c/Hotlist | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/c/Hotlist b/c/Hotlist
index b543f28..6771775 100644
--- a/c/Hotlist
+++ b/c/Hotlist
@@ -1961,12 +1961,33 @@ _kernel_oserror * hotlist_add(char * description, char * url, int at_bottom)
 {
   _kernel_oserror * e = NULL;
   int               position;
+  hotlist_item    * target;
+  int               type;
 
-  position = at_bottom ? HOTLIST_POSITION_END : HOTLIST_POSITION_BEGINNING;
+  target = hotlist_find_selected_item();
+
+  if (!target)
+  {
+    position = at_bottom ? HOTLIST_POSITION_END : HOTLIST_POSITION_BEGINNING;
+    target = hotlist_root;
+    type = 1;
+  }
+  else
+  {
+    if (target->type == hl_directory)
+    {
+      position = HOTLIST_POSITION_BEGINNING;
+    }
+    else
+    {
+      position = HOTLIST_POSITION_AFTER;
+    }
+    type = 2;
+  }
 
   /* Add the item and ensure the window extent etc. is correct */
 
-  e = hotlist_new_url(hotlist_root,
+  e = hotlist_new_url(target,
                       position,
                       description,
                       url);
@@ -1987,10 +2008,27 @@ _kernel_oserror * hotlist_add(char * description, char * url, int at_bottom)
 
     case HOTLIST_POSITION_BEGINNING:
     {
-      hotlist_redraw_items(0,
-                           hotlist_count_displayed_items(hotlist_root->data.directory_content));
+      if (type == 1)
+      {
+        hotlist_redraw_items(0,
+                             hotlist_count_displayed_items(hotlist_root->data.directory_content));
+      }
+      else
+      {
+        if (target->flags & HOTLIST_D_IS_OPEN)
+        {
+          hotlist_redraw_items(hotlist_find_no_from_item(target),
+                               hotlist_count_displayed_items(hotlist_root->data.directory_content));
+        }
+      }
     }
     break;
+
+    case HOTLIST_POSITION_AFTER:
+    {
+      hotlist_redraw_items(hotlist_find_no_from_item(hotlist_newitem),
+                           hotlist_count_displayed_items(hotlist_root->data.directory_content));
+    }
   }
 
   if (!e) return hotlist_modified(HL_MODIFIED_ADD);
-- 
GitLab