From 6c5db55b5ed19c30794046d4b25ddb5114d97b7e Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Fri, 10 Feb 2012 20:09:11 +0100 Subject: [PATCH] ADDED: Topic support(requested). You can sort the various notes under different topics now. FIXED: There was another bug, which caused the list command to display the notes with a too high value of $maxlen. --- Changelog | 7 ++ README | 53 ++++++++++- TODO | 1 - VERSION | 2 +- binary-db/note | 218 ++++++++++++++++++++++++++++++++++--------- config/noterc | 12 ++- mysql-db/note | 244 ++++++++++++++++++++++++++++++++++++++----------- 7 files changed, 432 insertions(+), 105 deletions(-) diff --git a/Changelog b/Changelog index bc0503e..f0bc3d3 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,10 @@ +0.5: +ADDED: Topic support(requested). You can sort the various notes under + different topics now. +FIXED: There was another bug, which caused the list command to display + the notes with a too high value of $maxlen. + + 0.4.2: ADDED: If run in interactive mode, note will at first do a list command. FIXED: A bug caused note to save bogus timestamps after editing a note. diff --git a/README b/README index 287fd77..baacd24 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -note 0.4.2 by Thomas Linden, 23/01/2000 +note 0.5 by Thomas Linden, 23/01/2000 Introduction @@ -13,7 +13,9 @@ Introduction You can add, edit, list and delete as many notes as you want. You can run note from the commandline - or interactive from within your console. + or interactive from within your console. You can + sort your notes in different topics, which is usefull + if you have a lot of them. There are now two version of note in one package: o (binary) the binary version resists in the @@ -86,7 +88,12 @@ Usage If you want to get an overview of all notes, type "note -l". You will get a list of all notes, containing the number, - the first line and the creation date. + the first line and the creation date. If topic-support is + turned on (which is by default), then "-l" will display a list + of all existing topics. If you want to get a listing of all + notes under a certain topic, use "-l topicname". You will get + timestamps, if you use "-L" instead of "-l". Read more about + topics below in the section "Topics". To edit a certain note, type "note -e 1". It will invoke your editor (vi or pico). You can edit it, after saving, note @@ -98,6 +105,9 @@ Usage existent notes. For example there are 3 notes, number 1, 2 and 3. If you delete number 2, then number 3 will become number 2. + You can also make use of the extended delete-syntax: + To delete note 1 and 2, use "-d 1,2" + To delete note 1,2 and 3, use "-d 1-3". If you cannot remember, which note you are looking for, you can use the search capability of note: "note -s ". @@ -107,7 +117,7 @@ Usage Instead of using note from the commandline you can use the interactive mode. Run note with "note -i". If you need assistance - type "?" or "h" at the "command>" prompt. The interactive mode + type "?" or "h" at the ">" prompt. The interactive mode provides you the most functions of note. You can also dump the contents of your note-database into a @@ -120,6 +130,41 @@ Usage +Topics +====== + + If topic-support is turned on (which is by default), the various + notes are sorted under various topics. There is no special database + field for the topic. Instead the topic will be stored right in the + note. + If the first line of your note contains some text bordered by back- + slashes, then note will consider it as the topic of this certain + note. For examle: + \TodoList\ + + If you are in interactive mode, you can "cd" to a different note simply + by typing it's name at the command-prompt. The list-command will only + show you notes under this topic. If you create a new note, it will auto- + magically inserted under the current topic (note will prepend the string + "\topicname\" to the text of your note). + + You can create at any time form any point a new topic. Just create a new + note and type yourself the name of the new topic bordered by backslashes + at the first line of this note. After saving, there will be available a + new topic with one note in it. + + If a note does not contain the "magic" \topic\ construction on the first + line, it will be listed under the topic "default". Therefore never use the + word "default" as a topic-name :-) + + You can subsequently move a note without a topic to a certain topic. Simply + edit it and insert at the first line the above mentioned construction. + + Note: Please don't forget the prepending and appending backslash of a topic. + You will get strange results without it! + + + Format of the notedb (binary version) ===================================== diff --git a/TODO b/TODO index d037ea7..03ee4a3 100644 --- a/TODO +++ b/TODO @@ -1,2 +1 @@ -- add topic and subtopic support some day... - dump to palm compatible format (!) any help out there? diff --git a/VERSION b/VERSION index 2b7c5ae..2eb3c4f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.2 +0.5 diff --git a/binary-db/note b/binary-db/note index e97bf33..cb3ce7a 100755 --- a/binary-db/note +++ b/binary-db/note @@ -7,8 +7,6 @@ # ones and, of course display them. # The notes will be stored in a binary data file (~/.notedb) # -# Previous versions needed a mysql database. This is no more -# the case. # If there exists a configfile called ~/.noterc then it will # be processed. You can overwrite some default values of note. # @@ -40,6 +38,10 @@ $BORDER_COLOR = "BLACK"; $NUM_COLOR = "blue"; $NOTE_COLOR = "magenta"; $TIME_COLOR = "black"; +$TOPIC_COLOR = "BLACK"; + +# Turns Topic Support on +$TOPIC = 1; ################################################# @@ -61,7 +63,7 @@ sub import; use IO::Seekable; -$version = "0.4.2 (binary database)"; +$version = "0.5 (binary database)"; # process command line args @@ -93,14 +95,16 @@ else elsif($ARGV[0] eq "-l" || $ARGV[0] eq "--list") { $mode = "list"; + $CurTopic = $ARGV[1]; $ARGV[0] = ""; } - elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist") - { - $mode = "list"; - $ListType = "LONG"; - $ARGV[0] = ""; - } + elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist") + { + $mode = "list"; + $ListType = "LONG"; + $CurTopic = $ARGV[1]; + $ARGV[0] = ""; + } elsif($ARGV[0] eq "-s" || $ARGV[0] eq "--search") { # searching @@ -159,7 +163,7 @@ else } elsif($ARGV[0] eq "-v" || $ARGV[0] eq "--version") { - print "This is note $version from Thomas Linden .\n"; + print "This is note $version by Thomas Linden .\n"; exit(0); } elsif($ARGV[0] eq "-h" || $ARGV[0] eq "--help") @@ -212,6 +216,8 @@ $NOTEC = "<$NOTE_COLOR>"; $_NOTEC = ""; $TIMEC = "<$TIME_COLOR>"; $_TIMEC = ""; +$TOPICC = "<$TOPIC_COLOR>"; +$_TOPICC = ""; $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; @@ -220,7 +226,7 @@ $typedef = "i a$MAX_NOTE a$MAX_TIME"; $sizeof = length pack($typedef, () ); -if($ListType ne "LONG") +if($ListType ne "LONG" && $mode ne "interactive") { $maxlen += $timelen; # no time will be displayed! } @@ -339,17 +345,84 @@ sub search ############################### LIST ################################## sub list { + if($mode ne "interactive") + { + if($TOPIC && $CurTopic eq "") + { + print "List of all available topics:\n\n"; + } + elsif($TOPIC && $CurTopic ne "") + { + print "List of all notes under topic \"$CurTopic\":\n\n"; + } + else + { + print "List of all existing notes:\n\n"; + } + } open (NOTE, "+<$NOTEDB") or die "could not open .notedb\n"; seek(NOTE, 0, 0); # START FROM BEGINNING - #print "listing all existing notes:\n\n"; + if($TOPIC && $CurTopic eq "") + { + undef %TP; + } while(read(NOTE, $buffer, $sizeof)) { ($num, $note, $time) = unpack($typedef, $buffer); - $n = ude($note); $t = ude($time); - #print "#$num:\t$t\n---\n$n\n\n"; - output($num, $n, $t); - } + $n = ude($note); + if($TOPIC) + { + # this allows us to have multiple topics (subtopics!) + @topic = split(/\\/,$n); + if($CurTopic eq "") + { + # looks like: "\topic\" + # collect: + if($topic[1] eq "") + { + $topic[1] = "default"; + } + if(exists $TP{$topic[1]}) + { + $TP{$topic[1]}++; + } + else + { + $TP{$topic[1]} = 1; + } + + } + else + { + if($topic[1] eq $CurTopic) + { + # cut the topic from the note-text + if($n =~ /^\\$CurTopic\\\n*/) + { + $n = $'; + } + output($num, $n, $t); + } + elsif($topic[1] eq "" && $CurTopic eq "default") + { + output($num, $n, $t); + } + } + } + else + { + output($num, $n, $t); + } + } + if($TOPIC && $CurTopic eq "") + { + # we are at top level, print a list of topics... + foreach $top (sort(keys %TP)) + { + print C " => " . $BORDERC. "[" . $_BORDERC . $TOPICC . $top . $_TOPICC . $BORDERC . "]" .$_BORDERC ." ($TP{$top} notes)\n"; + } + } close(NOTE); print "\n"; } @@ -375,7 +448,13 @@ sub new # read it in ($note) $note = ""; #open E, "<$TEMP" or die "Could not open $TEMP\n"; - open E, "<$TEMP" or print "...edit process interupted! No note has been saved.\n"; return; + open E, "<$TEMP" or $WARN = 1; + if($WARN) + { + print "...edit process interupted! No note has been saved.\n"; + undef $WARN; + return; + } $c = 0; while() { @@ -412,6 +491,16 @@ sub new seek(N, 0, 0); close (N); $num++; # use the highest plus 1 + + if($TOPIC && $CurTopic ne "") + { + @topic = split(/\\/,$note); + if($topic[1] eq "") + { + $note = "\\$CurTopic\\\n$note"; + } + } + open (NOTE, "+<$NOTEDB") or die "could not open .notedb\n"; seek(NOTE, 0, SEEK_END); # APPEND @@ -646,44 +735,47 @@ sub interactive # create menu: local $B = ""; local $BB = ""; - local $menu = "[ " . $B . "L" . $BB . " List " + local $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 ] command> "; + . $B . "E" . $BB . " Edit "; + if($TOPIC) + { + $menu .= $B . "T" . $BB . " Topic "; + } + $menu .= $B . "?" . $BB . " Help " + . $B . "Q" . $BB . " Quit] "; # $CurTopic will be empty if $TOPIC is off! # Initially do a list command! $maxlen += $timelen; + print "\n"; &list; # per default let's list all the stuff: for(;;) { - #&list; # reset time $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; $ListType = ""; $maxlen = $maxlen_save; - print C $menu; + print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; # endless until user press "Q" or "q"! $char = ; chomp $char; if($char =~ /^\d+/) { # display notes - $maxlen += $timelen; $number = $char; &display; } - elsif($char =~ /^n/i) + elsif($char =~ /^n$/i) { # create a new one $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; &new; } - elsif($char =~ /^l/ || $char =~ /^$/) + elsif($char =~ /^l$/ || $char =~ /^$/) { # list print "\n"; @@ -692,13 +784,14 @@ sub interactive &list; undef $SetTitle; } - elsif($char =~ /^L/) + elsif($char =~ /^L$/) { $ListType = "LONG"; + print "\n"; &list; undef $SetTitle; } - elsif($char =~ /^h/i || $char =~ /^\?/) + elsif($char =~ /^h$/i || $char =~ /^\?/) { # zu dumm der Mensch ;-) &help; @@ -729,7 +822,7 @@ sub interactive elsif($char =~ /^e$/i) { # we have to ask her: - $maxlen += $timelen; + #$maxlen += $timelen; print "enter number of the note you want to edit: "; $char = ; chomp $char; @@ -739,7 +832,6 @@ sub interactive elsif($char =~ /^s\s+/i) { # she want's to search - $maxlen += $timelen; $searchstring = $'; chomp $searchstring; &search; @@ -754,16 +846,45 @@ sub interactive $searchstring = $char; &search; } - elsif($char =~ /^q/i) + elsif($char =~ /^q$/i) { # schade!!! print "\n\ngood bye\n"; exit(0); } + elsif($char =~ /^t$/i && $TOPIC) + { + $SaveTopic = $CurTopic; + $CurTopic = ""; + #$maxlen += $timelen; + print "\n"; + &list; + $CurTopic = $SaveTopic; + undef $SetTitle; + } + elsif($char =~ /^\.\.$/) + { + $CurTopic = "default"; + $maxlen += $timelen; + print "\n"; + &list; + undef $SetTitle; + } else { # unknown - print "\nunknown command!\n"; + if(exists $TP{$char}) + { + $CurTopic = $char; + $maxlen += $timelen; + print "\n"; + &list; + undef $SetTitle; + } + else + { + print "\nunknown command!\n"; + } } } } @@ -779,8 +900,9 @@ Usage: note [-i | --interactive] | [ options ] [ number [,number...]] Options: -h --help displays this help screen -v --version displays the version number - -l --list lists all existing notes - -L --longlist the same as -l but prints also the timestamp + -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 -s --search searches for trough the notes database -e --edit edit note with -d --delete delete note with @@ -1026,16 +1148,26 @@ print qq~ 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. +L/l List notes. L=long, with timestamp and l=short without timestamp. + You can also just hit for short list. 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. -S Search trough the notes database. Usage is similar to - Delete, use a string instead of a number to search for. -E Edit a note. Usage is similar to Delete but you can - only edit one note a time. +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. +S Search trough the notes database. Usage is similar to Delete, use + a string instead of a number to search for. +E Edit a note. Usage is similar to Delete but you can only edit note + a time.~; +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.~; +} +print qq~ ?/H This help screen. Q Exit the program. diff --git a/config/noterc b/config/noterc index 8b1f561..dfca500 100644 --- a/config/noterc +++ b/config/noterc @@ -1,4 +1,4 @@ -# 0.4 +# 0.5 # This is a sample config for the note script # You do not need it, if you keep the values # here unchanged. @@ -8,7 +8,7 @@ # IMPORTANT: # If you previously used note 0.1 or 0.2 then # you will already have such a file. This file -# is not compatible with the one for note 0.3! +# is not compatible with the one for note 0.3 and higher! # You have to delete it and to create a new one. # # This config has to be valid perl code. Therefore @@ -16,7 +16,7 @@ # # You can contact me per email: # -# Thomas Linden, 01/2000 +# Thomas Linden, 23/2000 # mysql database settings. leave them uncommented @@ -41,6 +41,11 @@ #$ALWAYS_EDIT = "YES" +# This option turns topic-support on or off +# comment it out, if you don't need it +$TOPIC = 1; + + # Define the maximum bytes a note can have in a # note-entry. $MAX_NOTE = 1024; @@ -76,6 +81,7 @@ $BORDER_COLOR = "BLACK"; # Borders $NUM_COLOR = "blue"; # Note number $NOTE_COLOR = "magenta"; # The note itself $TIME_COLOR = "black"; # The time +$TOPIC_COLOR = "BLACK"; # The topic "prompt" # The following colors are available: # black, red, green, yellow, blue, magenta, cyan and white. diff --git a/mysql-db/note b/mysql-db/note index ed3857a..fe3338f 100755 --- a/mysql-db/note +++ b/mysql-db/note @@ -56,6 +56,10 @@ $BORDER_COLOR = "BLACK"; $NUM_COLOR = "blue"; $NOTE_COLOR = "magenta"; $TIME_COLOR = "black"; +$TOPIC_COLOR = "BLACK"; + +# Turns Topic Support on +$TOPIC = 1; ################################### @@ -75,7 +79,7 @@ sub list; sub help; sub import; -$version = "0.4.2 (mysql database)"; +$version = "0.5 (mysql database)"; # process command line args if($ARGV[0] eq "") @@ -98,22 +102,24 @@ else } $ARGV[0] = ""; } - elsif($ARGV[0] eq "-i" || $ARGV[0] eq "--interactive") - { - $mode = "interactive"; - $ARGV[0] = ""; - } + elsif($ARGV[0] eq "-i" || $ARGV[0] eq "--interactive") + { + $mode = "interactive"; + $ARGV[0] = ""; + } elsif($ARGV[0] eq "-l" || $ARGV[0] eq "--list") { $mode = "list"; + $CurTopic = $ARGV[1]; $ARGV[0] = ""; } - elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist") - { - $mode = "list"; - $ListType = "LONG"; - $ARGV[0] = ""; - } + elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist") + { + $mode = "list"; + $ListType = "LONG"; + $CurTopic = $ARGV[1]; + $ARGV[0] = ""; + } elsif($ARGV[0] eq "-s" || $ARGV[0] eq "--search") { # searching @@ -172,7 +178,7 @@ else } elsif($ARGV[0] eq "-v" || $ARGV[0] eq "--version") { - print "This is note $version from Thomas Linden .\n"; + print "This is note $version by Thomas Linden .\n"; exit(0); } elsif($ARGV[0] eq "-h" || $ARGV[0] eq "--help") @@ -214,15 +220,14 @@ $NOTEC = "<$NOTE_COLOR>"; $_NOTEC = ""; $TIMEC = "<$TIME_COLOR>"; $_TIMEC = ""; +$TOPICC = "<$TOPIC_COLOR>"; +$_TOPICC = ""; $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; -$typedef = "i a$MAX_NOTE a$MAX_TIME"; -$sizeof = length pack($typedef, () ); - -if($ListType ne "LONG") +if($ListType ne "LONG" && $mode ne "interactive") { $maxlen += $timelen; # no time will be displayed! } @@ -233,6 +238,7 @@ $db = Mysql->connect($dbhost,$dbname,$dbuser,$dbpasswd) or die "ERROR: $Mysql::dberrstr\n"; + # main loop: ############### if($mode eq "display") { @@ -337,14 +343,87 @@ sub search ############################### LIST ################################## sub list { + if($mode ne "interactive") + { + if($TOPIC && $CurTopic eq "") + { + print "List of all available topics:\n\n"; + } + elsif($TOPIC && $CurTopic ne "") + { + print "List of all notes under topic \"$CurTopic\":\n\n"; + } + else + { + print "List of all existing notes:\n\n"; + } + } + # list all available notes (number and firstline) $res = $db->query("SELECT $fnum,$fnote,$fdate FROM $table ORDER BY $fnum") or die "ERROR: $Mysql::dberrstr\n"; + if($TOPIC && $CurTopic eq "") + { + undef %TP; + } + while(@row = $res->fetchrow) { - output($row[0], $row[1], $row[2]); + #output($row[0], $row[1], $row[2]); + $num = $row[0]; $n = $row[1]; $t = $row[2]; + if($TOPIC) + { + @topic = split(/\\/,$n); # this allows us to have multiple topics (subtopics!) + if($CurTopic eq "") + { + # looks like: "\topic\" + # collect: + if($topic[1] eq "") + { + $topic[1] = "default"; + } + if(exists $TP{$topic[1]}) + { + $TP{$topic[1]}++; + } + else + { + $TP{$topic[1]} = 1; + } + } + else + { + if($topic[1] eq $CurTopic) + { + # cut the topic from the note-text + if($n =~ /^\\$CurTopic\\\n*/) + { + $n = $'; + } + output($num, $n, $t); + } + elsif($topic[1] eq "" && $CurTopic eq "default") + { + output($num, $n, $t); + } + } + } + else + { + output($num, $n, $t); + } + } - + if($TOPIC && $CurTopic eq "") + { + # we are at top level, print a list of topics... + foreach $top (sort(keys %TP)) + { + print C " => " . $BORDERC. "[" . $_BORDERC . $TOPICC + . $top . $_TOPICC . $BORDERC . "]" + .$_BORDERC ." ($TP{$top} notes)\n"; + } + } print "\n"; } @@ -369,7 +448,13 @@ sub new # read it in ($note) $note = ""; #open E, "<$TEMP" or die "Could not open $TEMP\n"; - open E, "<$TEMP" or print "...edit process interupted! No note has been saved.\n"; return; + open E, "<$TEMP" or $WARN = 1; + if($WARN) + { + print "...edit process interupted! No note has been saved.\n"; + undef $WARN; + return; + } $c = 0; while() { @@ -406,6 +491,18 @@ sub new $number = $row[0]; } $number++; + if($TOPIC && $CurTopic ne "") + { + @topic = split(/\\/,$note); + if($topic[1] eq "") + { + $note = "\\$CurTopic\\\n$note"; + } + } + + # mask all occuring \'s + $note =~ s/\\/\\\\/g; + $sqlstatement = "INSERT INTO $table VALUES ($number,'$note','$date')"; $db->query($sqlstatement) @@ -500,6 +597,9 @@ sub edit close NOTE; system "/bin/rm -f $TEMP"; + + # mask all occuring \'s + $note =~ s/\\/\\\\/g; # we got it, now save to db $sqlstatement = "UPDATE $table SET " @@ -588,43 +688,46 @@ sub interactive # create menu: local $B = ""; local $BB = ""; - local $menu = "[ " . $B . "L" . $BB . " List " + local $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 ] command> "; + . $B . "E" . $BB . " Edit "; + if($TOPIC) + { + $menu .= $B . "T" . $BB . " Topic "; + } + $menu .= $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; + print "\n"; &list; for(;;) { - #&list; $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; $ListType = ""; $maxlen = $maxlen_save; - print C $menu; + print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; # endless until user press "Q" or "q"! $char = ; chomp $char; if($char =~ /^\d+/) { # display notes - $maxlen += $timelen; $number = $char; &display; } - elsif($char =~ /^n/i) + elsif($char =~ /^n$/i) { # create a new one $time = `date +%d\".\"%m\".\"%Y\" \"%T`; chomp $time; &new; } - elsif($char =~ /^l/ || $char =~ /^$/) + elsif($char =~ /^l$/ || $char =~ /^$/) { # list print "\n"; @@ -633,13 +736,14 @@ sub interactive &list; undef $SetTitle; } - elsif($char =~ /^L/) + elsif($char =~ /^L$/) { $ListType = "LONG"; + print "\n"; &list; undef $SetTitle; } - elsif($char =~ /^h/i || $char =~ /^\?/) + elsif($char =~ /^h$/i || $char =~ /^\?/) { # zu dumm der Mensch ;-) &help; @@ -679,7 +783,6 @@ sub interactive elsif($char =~ /^s\s+/i) { # she want's to search - #$maxlen += $timelen; $searchstring = $'; chomp $searchstring; &search; @@ -687,7 +790,6 @@ sub interactive elsif($char =~ /^s$/i) { # we have to ask her: - #$maxlen += $timelen; print "enter the string you want to search for: "; $char = ; chomp $char; @@ -695,16 +797,45 @@ sub interactive $searchstring = $char; &search; } - elsif($char =~ /^q/i) + elsif($char =~ /^q$/i) { # schade!!! print "\n\ngood bye\n"; exit(0); } + elsif($char =~ /^t$/i && $TOPIC) + { + $SaveTopic = $CurTopic; + $CurTopic = ""; + #$maxlen += $timelen; + print "\n"; + &list; + $CurTopic = $SaveTopic; + undef $SetTitle; + } + elsif($char =~ /^\.\.$/) + { + $CurTopic = "default"; + $maxlen += $timelen; + print "\n"; + &list; + undef $SetTitle; + } else { # unknown - print "\nunknown command!\n"; + if(exists $TP{$char}) + { + $CurTopic = $char; + $maxlen += $timelen; + print "\n"; + &list; + undef $SetTitle; + } + else + { + print "\nunknown command!\n"; + } } } } @@ -720,8 +851,9 @@ Usage: note [-i | --interactive] | [ options ] [ number [,number...]] Options: -h --help displays this help screen -v --version displays the version number - -l --list lists all existing notes - -L --longlist the same as -l but prints also the timestamp + -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 -s --search searches for trough the notes database -e --edit edit note with -d --delete delete note with @@ -967,24 +1099,30 @@ print qq~ 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. -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. -S Search trough the notes database. Usage is similar to - Delete, use a string instead of a number to search for. -E Edit a note. Usage is similar to Delete but you can - only edit one note a time. -?/H This help screen. -Q Exit the program. +L/l List notes. L=long, with timestamp and l=short without timestamp. + You can also just hit for short list. +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. +S Search trough the notes database. Usage is similar to Delete, use + a string instead of a number to search for. +E Edit a note. Usage is similar to Delete but you can only edit note + a time.~; +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.~; +} +print qq~ +?/H This help screen. +Q Exit the program. All commands except the List command are case insensitive. --------------------------------------------------------------- ~; } - - - -