diff --git a/Changelog b/Changelog
index 624d103..8bbbc24 100644
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,13 @@
==================================================================================
+1.0.2:
+ADDED: Topic-Tree overview command (-t or -T).
+ADDED: Enhanced list command in interactive mode, you can now specify
+ a topic which notes you want to see.
+CHANGED: updated the help and usage sections to reflect the additions above.
+
+==================================================================================
+
1.0.1:
FIXED: fixed bug in NOTEDB::mysql, which caused note t store NULL values
in db, if encryption was off. A really dump failure :-(
diff --git a/README b/README
index 0c6b1cf..39b103d 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-note 1.0.1 by Thomas Linden, 18/04/2000
+note 1.0.2 by Thomas Linden, 01/05/2000
Introduction
@@ -102,6 +102,13 @@ Usage
If you want to get a listing of all
If you want to see the timestamps, use "-L" instead of "-l".
Read more about topics below in the section "Topics".
+ You can also specify the topic which notes you want to see:
+ "-l mytopic" does the trick.
+ Additional, you might want to get an overview of your topic-
+ strcture. You can use the command "-t" in this case, which
+ will display a tree-view of your tpic-structure. You can
+ use the command "-T" if you want to see the notes under each
+ topic too.
To edit a certain note, type "note -e 1". It will invoke your
editor (vi or pico). You can edit it, after saving, note
diff --git a/VERSION b/VERSION
index 7dea76e..6d7de6e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.1
+1.0.2
diff --git a/bin/note b/bin/note
index c0ea70d..3eb3521 100755
--- a/bin/note
+++ b/bin/note
@@ -1,7 +1,20 @@
#!/usr/bin/perl
-# $Author: thomas $ $Id: note,v 1.15 2000/03/19 23:41:04 thomas Exp thomas $ $Revision: 1.15 $
+# $Author: thomas $ $Id: note,v 1.19 2000/04/30 16:07:23 thomas Exp thomas $ $Revision: 1.19 $
#
# $Log: note,v $
+# Revision 1.19 2000/04/30 16:07:23 thomas
+# *** empty log message ***
+#
+# Revision 1.18 2000/04/30 14:58:21 thomas
+# updated the usage and help subs
+#
+# Revision 1.17 2000/04/30 14:44:38 thomas
+# added colors to the tree functions
+#
+# Revision 1.16 2000/04/30 14:28:38 thomas
+# added the t command, which displays a topic-tree.
+# and enhanced the list command in interactive mode
+#
# Revision 1.15 2000/03/19 23:41:04 thomas
# changed set_del, now no extra TEMP file is required!
# instead I get it from $this->get_all() !
@@ -82,12 +95,14 @@ sub display;
sub list;
sub help;
sub import;
+sub display_tree;
+sub tree;
my (
- $maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB,
- $version, $number, $CurTopic, $CurDepth, $PATH, $CONF,
+ $maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB, $NoteKey,
+ $version, $number, $CurTopic, $CurDepth, $PATH, $CONF, $WantTopic,
$sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep,
- $ListType, $searchstring, $dump_file, $ALWAYS_INT, $KEEP_TIMESTAMP,
+ $TreeType, $ListType, $searchstring, $dump_file, $ALWAYS_INT, $KEEP_TIMESTAMP,
$BORDERC, $BORDER_COLOR, $_BORDERC, $NOTEC, $NOTE_COLOR,
$NUMC, $NUM_COLOR, $_NUMC, $_NOTEC, $TIMEC, $TIME_COLOR,
$_TIMEC, $TOPICC, $TOPIC_COLOR, $_TOPICC, $SetTitle, $COLOR,
@@ -121,7 +136,7 @@ $TIME_COLOR = "black";
$TOPIC_COLOR = "BLACK";
$TOPIC = 1;
$TopicSep = '/';
-$version = "1.0.1";
+$version = "1.0.2";
if($TOPIC)
{
$CurDepth = 1; # the current depth inside the topic "directory" structure...
@@ -155,6 +170,17 @@ else
$mode = "interactive";
$ARGV[0] = "";
}
+ elsif($ARGV[0] eq "-t" || $ARGV[0] eq "--tree")
+ {
+ $mode = "tree";
+ $ARGV[0] = "";
+ }
+ elsif($ARGV[0] eq "-T" || $ARGV[0] eq "--longtree")
+ {
+ $mode = "tree";
+ $TreeType = "LONG";
+ $ARGV[0] = "";
+ }
elsif($ARGV[0] eq "-l" || $ARGV[0] eq "--list")
{
$mode = "list";
@@ -300,6 +326,7 @@ $_TIMEC = "$TIME_COLOR>";
$TOPICC = "<$TOPIC_COLOR>";
$_TOPICC = "$TOPIC_COLOR>";
+$NoteKey = $TopicSep . "notes" . $TopicSep;
if($ListType ne "LONG" && $mode ne "interactive")
@@ -334,7 +361,7 @@ if($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
my ($note, $date) = $db->get_single(1);
if($date ne "") {
if($date !~ /^\d+\.\d+?/) {
- print "access denied.\n";
+ print "access denied.\n"; # decrypted $date is not a number!
exit(1);
}
} #else empty!
@@ -357,6 +384,10 @@ elsif($mode eq "list")
{
&list;
}
+elsif($mode eq "tree")
+{
+ &display_tree;
+}
elsif($mode eq "new")
{
&new;
@@ -789,13 +820,16 @@ sub interactive
# create menu:
$B = "";
$BB = "";
- $menu = "[" . $B . "L" . $BB . " List "
- . $B . "N" . $BB . " New "
- . $B . "D" . $BB . " Delete "
- . $B . "S" . $BB . " Search "
- . $B . "E" . $BB . " Edit "
- . $B . "?" . $BB . " Help "
- . $B . "Q" . $BB . " Quit] "; # $CurTopic will be empty if $TOPIC is off!
+ $menu = "[" . $B . "L" . $BB . " List ";
+ if($TOPIC) {
+ $menu .= $B . "T" . $BB . " Topics ";
+ }
+ $menu .= $B . "N" . $BB . " New "
+ . $B . "D" . $BB . " Delete "
+ . $B . "S" . $BB . " Search "
+ . $B . "E" . $BB . " Edit "
+ . $B . "?" . $BB . " Help "
+ . $B . "Q" . $BB . " Quit] "; # $CurTopic will be empty if $TOPIC is off!
# per default let's list all the stuff:
# Initially do a list command!
$maxlen += $timelen;
@@ -906,6 +940,16 @@ sub interactive
print "\n\ngood bye\n";
exit(0);
}
+ elsif($char =~ /^t$/)
+ {
+ &display_tree;
+ }
+ elsif($char =~ /^T$/)
+ {
+ $TreeType = "LONG";
+ &display_tree;
+ $TreeType = "";
+ }
elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/)
{
$CurDepth-- if ($CurDepth > 1);
@@ -915,6 +959,30 @@ sub interactive
&list;
undef $SetTitle;
}
+ elsif($char =~ /^l\s+(\w+)$/)
+ {
+ # list
+ $WantTopic = $1;
+ if(exists $TP{$WantTopic})
+ {
+ my %SaveTP = %TP;
+ $LastTopic[$CurDepth] = $CurTopic;
+ $CurTopic = $1;
+ $CurDepth++;
+ print "\n";
+ $ListType = "";
+ $maxlen += $timelen;
+ &list;
+ undef $SetTitle;
+ $CurTopic = $LastTopic[$CurDepth];
+ $CurDepth--;
+ %TP = %SaveTP;
+ }
+ else
+ {
+ print "\nunknown command!\n";
+ }
+ }
else
{
# unknown
@@ -954,6 +1022,8 @@ Options:
-l --list [] lists all existing notes If no topic were specified,
it will display a list of all existing topics.
-L --longlist [] the same as -l but prints also the timestamp
+ -t --topic prints a list of all topics as a tree.
+ -T --longtopc prints the topic-tree with the notes under each topic
-s --search searches for trough the notes database
-e --edit edit note with
-d --delete delete note with
@@ -1233,6 +1303,8 @@ HELP for interactive note $version
The following commands are available:
L/l List notes. L=long, with timestamp and l=short without timestamp.
You can also just hit for short list.
+ If you specify a subtopic, then list will display it's contents, i.e.
+ "l mytopic" will dislpay notes under mytopic.
N Create a new note.
D Delete a note. You can either hit "d 1" or "d 1-4" or just hit "d".
If you don't specify a number, you will be asked for.
@@ -1243,12 +1315,18 @@ E Edit a note. Usage is similar to Delete but you can only edit note
if($TOPIC)
{
print qq~
-T print a list of all existing topics. You can change the actual
- topic by simply typing it's name. You can create a new topic by
- creating a new note, the first line must be the topic borderd by
- backslashes, i.e.: "\\newtopic\\". If you type just ".." instead
- of a topic, you will go to the "default" topic, which contains
- all notes without a topic.~;
+T/t print a list of all existing topics as a tree. T prints the tree with
+ all notes under each topic.
+ =====>
+ You can change the actual topic by simply typing it's name or by
+ using the command "cd", i.e. "cd mytopic".
+ You can create a new topic by creating a new note, the first line
+ must be the topic borderd by slashes, i.e. "/newtopic/". The slash
+ is the default topic-sepearator, but you can override thie in the
+ config!
+ If you type just ".." instead of a topic, you will go one step back
+ in your topic-structure.
+ =====>~;
}
print qq~
?/H This help screen.
@@ -1258,3 +1336,69 @@ All commands except the List command are case insensitive.
---------------------------------------------------------------
~;
}
+
+
+sub display_tree {
+ # displays a tree of all topics
+ my(%TREE, %res, $n, $t, $num, @nodes, $firstline, $text, $untext);
+ %res = $db->get_all();
+ foreach $num (keys %res)
+ {
+ $n = $res{$num}->{'note'};
+ $t = $res{$num}->{'date'};
+ # this allows us to have multiple topics (subtopics!)
+ my ($firstline,$text,$untext) = split /\n/, $n, 3;
+ if($firstline =~ /^($TopicSep)/)
+ {
+ $firstline =~ s/($TopicSep)*$//; #remove TopicSepatator
+ @nodes = split(/$TopicSep/,$firstline);
+ }
+ else
+ {
+ @nodes = ();("$TopicSep");
+ $text = $firstline;
+ }
+ &tree($text, \%TREE, @nodes);
+ }
+
+ # now that we have build our tree (in %TREE) go on t display it:
+ print C $BORDERC . "\n[" . $TopicSep . $BORDERC . "]\n";
+ &print_tree(\%{$TREE{''}},"");
+ print C $BORDERC . $_BORDERC . "\n";
+}
+
+
+sub tree {
+ my($text, $LocalTree, $node, @nodes) = @_;
+ if(@nodes) {
+ if(! exists $LocalTree->{$node}->{$NoteKey}) {
+ $LocalTree->{$node}->{$NoteKey} = [];
+ }
+ &tree($text, $LocalTree->{$node}, @nodes);
+ }
+ else {
+ push @{$LocalTree->{$node}->{$NoteKey}}, $text;
+ }
+}
+
+
+sub print_tree {
+ # thanks to Jens for his hints and this sub!
+ my $hashref=shift;
+ my $prefix=shift;
+ my @notes=@{$hashref->{$NoteKey}};
+ my @subnotes=sort grep { ! /^$NoteKey$/ } keys %$hashref;
+ if($TreeType eq "LONG") {
+ for my $note (@notes) {
+ if($note ne "") {
+ print C $BORDERC ;# . $prefix. "|\n";
+ print C "$prefix+---<" . $NOTEC . $note . $BORDERC . ">" . $_NOTEC . "\n";
+ }
+ }
+ }
+ for my $index (0..$#subnotes) {
+ print C $BORDERC . $prefix. "|\n";
+ print C "$prefix+---[" . $TOPICC . $subnotes[$index] . $BORDERC . "]\n";
+ &print_tree($hashref->{$subnotes[$index]},($index == $#subnotes?"$prefix ":"$prefix| "));
+ }
+}