[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#248798: hnb: Updated patch



Package: hnb
Version: 1.9.17-3
Severity: normal
Followup-For: Bug #248798


I didn't know how "recursive" the recursive function was in the last
patch. This one adds a function to recurse "right of" a certain node.
This makes the subtree expand/collapse behavior more consistent
regardless of location in the tree.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.5
Locale: LANG=C, LC_CTYPE=C

Versions of packages hnb depends on:
ii  libc6                       2.3.2.ds1-12 GNU C Library: Shared libraries an
ii  libncurses5                 5.4-3        Shared libraries for terminal hand

-- no debconf information
diff -ur hnb-1.9.17.orig/src/expanded.c hnb-1.9.17/src/expanded.c
--- hnb-1.9.17.orig/src/expanded.c	2003-03-13 15:31:18.000000000 -0600
+++ hnb-1.9.17/src/expanded.c	2004-05-13 00:26:54.000000000 -0500
@@ -26,7 +26,6 @@
 #include "ctype.h"
 #include "ui_binding.h"
 
-
 static int cmd_expand (int argc,char **argv, void *data)
 {
 	Node *pos = (Node *) data;
@@ -47,6 +46,18 @@
 			tnode = node_recurse (tnode);
 		}
 		cli_outfun ("expanded all nodes");
+	} else if(!strcmp(argv[1],"--subtree")) {
+	        node_setflag(pos,F_expanded,1);
+		if(node_right(pos)) {
+		  
+		  Node *tnode = node_right(pos);
+
+		  while (tnode) {
+		    node_setflag(tnode,F_expanded,1);
+		    tnode = node_traverse_right_of (pos, tnode);
+		  }
+		}
+		cli_outfun ("expanded subtree");
 	}
 	return (int) pos;
 }
@@ -71,6 +82,17 @@
 			tnode = node_recurse (tnode);
 		}
 		cli_outfun ("collapsed all nodes");
+	} else if(!strcmp(argv[1],"--subtree")) {
+	        node_setflag(pos,F_expanded,0);
+		if(node_right(pos)) {
+		  Node *tnode = node_right(pos);
+
+		  while (tnode) {
+		    node_setflag(tnode,F_expanded,0);
+		    tnode = node_traverse_right_of (pos, tnode);
+		  }
+		}
+		cli_outfun ("collapsed subtree");
 	}
 	
 	return (int) pos;
diff -ur hnb-1.9.17.orig/src/hnbrc.inc hnb-1.9.17/src/hnbrc.inc
--- hnb-1.9.17.orig/src/hnbrc.inc	2003-03-14 00:08:35.000000000 -0600
+++ hnb-1.9.17/src/hnbrc.inc	2004-05-12 23:17:59.000000000 -0500
@@ -216,6 +216,8 @@
 		\n\
 		bind + expand\n\
 		bind - collapse\n\
+		bind ] \"expand --subtree\"\n\
+		bind [ \"collapse --subtree\"\n\
 		\n\
 		bind ^Z restore_state\n\
 		\n\
@@ -515,17 +517,19 @@
 		menu \"Edit\" \"---------\" \"\"\n\
 		menu \"Edit\" \"Search ^F\" \"macro m_search\"\n\
 	##### node\n\
-		menu \"Entry\" \"--------------\" \"\"\n\
-		menu \"Entry\" \"edit    return\" \"edit\"\n\
-		menu \"Entry\" \"delete     del\" \"remove\"\n\
-		menu \"Entry\" \"--------------\" \"\"\n\
-		menu \"Entry\" \"do action   ^A\" \"action\"\n\
-		menu \"Entry\" \"indent      >\" \"indent\"\n\
-		menu \"Entry\" \"outdent     <\" \"outdent\"\n\
-		menu \"Entry\" \"toggle todo ^T\" \"toggle_todo\"\n\
-		menu \"Entry\" \"toggle done ^D\" \"toggle_done\"\n\
-		menu \"Entry\" \"expand      +\" \"expand\"\n\
-		menu \"Entry\" \"collapse    -\" \"collapse\"\n\
+		menu \"Entry\" \"-------------------\" \"\"\n\
+		menu \"Entry\" \"edit         return\" \"edit\"\n\
+		menu \"Entry\" \"delete          del\" \"remove\"\n\
+		menu \"Entry\" \"-------------------\" \"\"\n\
+		menu \"Entry\" \"do action        ^A\" \"action\"\n\
+		menu \"Entry\" \"indent           >\" \"indent\"\n\
+		menu \"Entry\" \"outdent          <\" \"outdent\"\n\
+		menu \"Entry\" \"toggle todo      ^T\" \"toggle_todo\"\n\
+		menu \"Entry\" \"toggle done      ^D\" \"toggle_done\"\n\
+		menu \"Entry\" \"expand           +\" \"expand\"\n\
+		menu \"Entry\" \"expand subtree   ]\" \"expand --subtree\"\n\
+		menu \"Entry\" \"collapse         -\" \"collapse\"\n\
+		menu \"Entry\" \"collapse subtree [\" \"collapse --subtree\"\n\
 	##### level\n\
 		menu \"Level\" \"------------\" \"\"\n\
 		menu \"Level\" \"sort      ^S\" \"sort -a\"\n\
Only in hnb-1.9.17/src: test2.hnb
Only in hnb-1.9.17/src: todo2.hnb
diff -ur hnb-1.9.17.orig/src/tree.c hnb-1.9.17/src/tree.c
--- hnb-1.9.17.orig/src/tree.c	2003-02-27 20:50:06.000000000 -0600
+++ hnb-1.9.17/src/tree.c	2004-05-13 00:25:26.000000000 -0500
@@ -47,6 +47,21 @@
 	return 0;
 }
 
+Node *node_traverse_right_of (Node *stop, Node *node)
+{
+	if (node_right (node))
+		return node_right (node);
+	if (node_down (node))
+		return node_down (node);
+	while (node_left (node) && (node_left (node) != stop)) {
+		if (node_down (node_left (node)))
+			return node_down (node_left (node));
+		node = node_left (node);
+	}
+
+	return 0;
+}
+
 Node *node_backrecurse (Node *node)
 {
 	if (node_up (node)) {

Reply to: