ADDED: one can now use the unix-like "cd" command to change to another

topic, thus use "cd topicname" instead just typing "topicname"!
FIXED:          there was a smal regex bug which maked it impossible to use such
                topics: "4 test", in such a case note just displayed note number 4
                instead of cd'ing to topic "4 test".
ADDED:          a new config option "$KEEP_TIMESTAMP" allows a user to disable
                note's default behavior of updating the timestamp of a note after
                editing it.
This commit is contained in:
TLINDEN
2012-02-10 20:12:09 +01:00
parent 142ff12b12
commit 1ab897790c
6 changed files with 541 additions and 151 deletions

View File

@@ -1,5 +1,19 @@
================================================================================== ==================================================================================
0.7:
ADDED: one can now use the unix-like "cd" command to change to another
topic, thus use "cd topicname" instead just typing "topicname"!
FIXED: there was a smal regex bug which maked it impossible to use such
topics: "4 test", in such a case note just displayed note number 4
instead of cd'ing to topic "4 test".
ADDED: a new config option "$KEEP_TIMESTAMP" allows a user to disable
note's default behavior of updating the timestamp of a note after
editing it.
==================================================================================
0.6: 0.6:
FIXED: oops - the new suptopic feature confused the commandline-mode of FIXED: oops - the new suptopic feature confused the commandline-mode of

2
README
View File

@@ -1,4 +1,4 @@
note 0.6 by Thomas Linden, 21/02/2000 note 0.7 by Thomas Linden, 08/03/2000
Introduction Introduction

View File

@@ -1 +1 @@
0.6 0.7

View File

@@ -1,8 +1,15 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
# $Id: note,v 1.7 2000/02/25 21:00:15 tom Exp tom $ $Author: tom $ $Revision: 1.7 $ # $Id: note,v 1.9 2000/03/08 23:11:08 tom Exp tom $ $Author: tom $ $Revision: 1.9 $
# #
# $Log: note,v $ # $Log: note,v $
# Revision 1.9 2000/03/08 23:11:08 tom
# added cd
#
# Revision 1.8 2000/03/08 22:49:50 tom
# Added the $KEEP_TIMESTAMP option and fixed a bug regarding topic names
# and invalid resolution of them in case it started with "1 name".
#
# Revision 1.7 2000/02/25 21:00:15 tom # Revision 1.7 2000/02/25 21:00:15 tom
# corrected small timestamp problem in &edit and &new # corrected small timestamp problem in &edit and &new
# #
@@ -67,7 +74,7 @@ my (
$maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB, $maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB,
$version, $number, $CurTopic, $CurDepth, $PATH, $CONF, $version, $number, $CurTopic, $CurDepth, $PATH, $CONF,
$sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep, $sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep,
$ListType, $searchstring, $dump_file, $ALWAYS_INT, $ListType, $searchstring, $dump_file, $ALWAYS_INT, $KEEP_TIMESTAMP,
$BORDERC, $BORDER_COLOR, $_BORDERC, $NOTEC, $NOTE_COLOR, $BORDERC, $BORDER_COLOR, $_BORDERC, $NOTEC, $NOTE_COLOR,
$NUMC, $NUM_COLOR, $_NUMC, $_NOTEC, $TIMEC, $TIME_COLOR, $NUMC, $NUM_COLOR, $_NUMC, $_NOTEC, $TIMEC, $TIME_COLOR,
$_TIMEC, $TOPICC, $TOPIC_COLOR, $_TOPICC, $SetTitle, $COLOR, $_TIMEC, $TOPICC, $TOPIC_COLOR, $_TOPICC, $SetTitle, $COLOR,
@@ -106,7 +113,7 @@ $TOPIC = 1;
# Default topic separator: \ # Default topic separator: \
$TopicSep = '/'; $TopicSep = '/';
$version = "0.6 (binary database)"; $version = "0.7 (binary database)";
if($TOPIC) if($TOPIC)
{ {
@@ -654,7 +661,7 @@ sub del
############################### EDIT ################################## ############################### EDIT ##################################
sub edit sub edit
{ {
my($time,$editor, $TEMP, $address, $n, $buff, $c, $note, $t, $buffer, $num); my($keeptime, $time,$editor, $TEMP, $address, $n, $buff, $c, $note, $t, $buffer, $num);
$time = &getdate; $time = &getdate;
$address = ($number -1 ) * $sizeof; $address = ($number -1 ) * $sizeof;
open (NOTE, "+<$NOTEDB") or die "could not open .notedb\n"; open (NOTE, "+<$NOTEDB") or die "could not open .notedb\n";
@@ -662,6 +669,7 @@ sub edit
read(NOTE, $buff, $sizeof) or die "no note with that number found!\n"; read(NOTE, $buff, $sizeof) or die "no note with that number found!\n";
($num, $note, $t) = unpack($typedef, $buff); ($num, $note, $t) = unpack($typedef, $buff);
$n = ude($note); $n = ude($note);
$keeptime = ude($t);
# got current enties... # got current enties...
# now edit them # now edit them
@@ -702,7 +710,14 @@ sub edit
seek(NOTE, $address, SEEK_SET); seek(NOTE, $address, SEEK_SET);
$n = ""; $n = "";
$n = uen($note); $n = uen($note);
$t = uen($time); if($KEEP_TIMESTAMP eq "YES")
{
$t = uen($keeptime);
}
else
{
$t = uen($time);
}
$buffer = pack($typedef, $number, $n, $t); $buffer = pack($typedef, $number, $n, $t);
print NOTE $buffer; print NOTE $buffer;
close(NOTE); close(NOTE);
@@ -845,7 +860,7 @@ sub interactive
# endless until user press "Q" or "q"! # endless until user press "Q" or "q"!
$char = <STDIN>; $char = <STDIN>;
chomp $char; chomp $char;
if($char =~ /^\d+/) if($char =~ /^\d+$/)
{ {
# display notes # display notes
$maxlen += $timelen; $maxlen += $timelen;
@@ -933,7 +948,7 @@ sub interactive
print "\n\ngood bye\n"; print "\n\ngood bye\n";
exit(0); exit(0);
} }
elsif($char =~ /^\.\.$/) elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/)
{ {
$CurDepth-- if ($CurDepth > 1); $CurDepth-- if ($CurDepth > 1);
$CurTopic = $LastTopic[$CurDepth]; $CurTopic = $LastTopic[$CurDepth];
@@ -945,8 +960,11 @@ sub interactive
else else
{ {
# unknown # unknown
if(exists $TP{$char}) my $unchar = $char;
$unchar =~ s/^cd //; # you may use cd <topic> now!
if(exists $TP{$char} || exists $TP{$unchar})
{ {
$char = $unchar if(exists $TP{$unchar});
$LastTopic[$CurDepth] = $CurTopic; $LastTopic[$CurDepth] = $CurTopic;
$CurTopic = $char; $CurTopic = $char;
$maxlen += $timelen; $maxlen += $timelen;
@@ -959,6 +977,7 @@ sub interactive
{ {
print "\nunknown command!\n"; print "\nunknown command!\n";
} }
undef $unchar;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
# 0.6 # 0.7
# This is a sample config for the note script # This is a sample config for the note script
# You do not need it, if you keep the values # You do not need it, if you keep the values
# here unchanged. # here unchanged.
@@ -41,15 +41,27 @@
#$ALWAYS_EDIT = "YES"; #$ALWAYS_EDIT = "YES";
# uncomment this, if you dont prefer that note updates
# the timestamp of a note after editing it. It will
# keep the original timestamp if this option is set.
#$KEEP_TIMESTAMP = "YES";
# uncomment and edit it, if you want to use another # uncomment and edit it, if you want to use another
# editor than the default $EDITOR or as fallback vi. # editor than the default $EDITOR or as fallback vi.
#$PreferredEditor = "emacs"; #$PreferredEditor = "emacs";
# This option turns topic-support on or off # This option turns topic-support on or off
# comment it out, if you don't need it # comment it out, if you don't need it
$TOPIC = 1; $TOPIC = 1;
# You can specify your own topic separator here.
# the default topic separator is a normal slash: "/"
#$TopicSep = '/';
# Define the maximum bytes a note can have in a # Define the maximum bytes a note can have in a
# note-entry. # note-entry.
$MAX_NOTE = 1024; $MAX_NOTE = 1024;

File diff suppressed because it is too large Load Diff