mirror of
https://codeberg.org/scip/note.git
synced 2025-12-17 20:51:02 +01:00
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:
@@ -1,8 +1,15 @@
|
||||
#!/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 $
|
||||
# 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
|
||||
# corrected small timestamp problem in &edit and &new
|
||||
#
|
||||
@@ -67,7 +74,7 @@ my (
|
||||
$maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB,
|
||||
$version, $number, $CurTopic, $CurDepth, $PATH, $CONF,
|
||||
$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,
|
||||
$NUMC, $NUM_COLOR, $_NUMC, $_NOTEC, $TIMEC, $TIME_COLOR,
|
||||
$_TIMEC, $TOPICC, $TOPIC_COLOR, $_TOPICC, $SetTitle, $COLOR,
|
||||
@@ -106,7 +113,7 @@ $TOPIC = 1;
|
||||
# Default topic separator: \
|
||||
$TopicSep = '/';
|
||||
|
||||
$version = "0.6 (binary database)";
|
||||
$version = "0.7 (binary database)";
|
||||
|
||||
if($TOPIC)
|
||||
{
|
||||
@@ -654,7 +661,7 @@ sub del
|
||||
############################### 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;
|
||||
$address = ($number -1 ) * $sizeof;
|
||||
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";
|
||||
($num, $note, $t) = unpack($typedef, $buff);
|
||||
$n = ude($note);
|
||||
$keeptime = ude($t);
|
||||
# got current enties...
|
||||
|
||||
# now edit them
|
||||
@@ -702,7 +710,14 @@ sub edit
|
||||
seek(NOTE, $address, SEEK_SET);
|
||||
$n = "";
|
||||
$n = uen($note);
|
||||
$t = uen($time);
|
||||
if($KEEP_TIMESTAMP eq "YES")
|
||||
{
|
||||
$t = uen($keeptime);
|
||||
}
|
||||
else
|
||||
{
|
||||
$t = uen($time);
|
||||
}
|
||||
$buffer = pack($typedef, $number, $n, $t);
|
||||
print NOTE $buffer;
|
||||
close(NOTE);
|
||||
@@ -845,7 +860,7 @@ sub interactive
|
||||
# endless until user press "Q" or "q"!
|
||||
$char = <STDIN>;
|
||||
chomp $char;
|
||||
if($char =~ /^\d+/)
|
||||
if($char =~ /^\d+$/)
|
||||
{
|
||||
# display notes
|
||||
$maxlen += $timelen;
|
||||
@@ -933,7 +948,7 @@ sub interactive
|
||||
print "\n\ngood bye\n";
|
||||
exit(0);
|
||||
}
|
||||
elsif($char =~ /^\.\.$/)
|
||||
elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/)
|
||||
{
|
||||
$CurDepth-- if ($CurDepth > 1);
|
||||
$CurTopic = $LastTopic[$CurDepth];
|
||||
@@ -945,8 +960,11 @@ sub interactive
|
||||
else
|
||||
{
|
||||
# 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;
|
||||
$CurTopic = $char;
|
||||
$maxlen += $timelen;
|
||||
@@ -959,6 +977,7 @@ sub interactive
|
||||
{
|
||||
print "\nunknown command!\n";
|
||||
}
|
||||
undef $unchar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user