mirror of
https://codeberg.org/scip/note.git
synced 2025-12-17 12:41:10 +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:
14
Changelog
14
Changelog
@@ -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
2
README
@@ -1,4 +1,4 @@
|
|||||||
note 0.6 by Thomas Linden, 21/02/2000
|
note 0.7 by Thomas Linden, 08/03/2000
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
|
|||||||
@@ -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);
|
||||||
|
if($KEEP_TIMESTAMP eq "YES")
|
||||||
|
{
|
||||||
|
$t = uen($keeptime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$t = uen($time);
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,4 +1,27 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
# $Author: tom $ $Id: note.mysql,v 1.7 2000/03/08 23:11:19 tom Exp tom $ $Revision: 1.7 $
|
||||||
|
#
|
||||||
|
# $Log: note.mysql,v $
|
||||||
|
# Revision 1.7 2000/03/08 23:11:19 tom
|
||||||
|
# added cd
|
||||||
|
#
|
||||||
|
# Revision 1.6 2000/03/08 22:50:41 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.5 2000/02/25 20:59:30 tom
|
||||||
|
# corrected small timestamp problem in &edit and &new
|
||||||
|
#
|
||||||
|
# Revision 1.4 2000/02/25 13:24:11 tom
|
||||||
|
# fixed a small bug, that caused to use the last line for a note title instead the 2nd.
|
||||||
|
#
|
||||||
|
# Revision 1.3 2000/02/25 11:28:53 tom
|
||||||
|
# all changes from bin version applied to sql version
|
||||||
|
#
|
||||||
|
# Revision 1.2 2000/02/25 10:30:06 tom
|
||||||
|
# *** empty log message ***
|
||||||
|
#
|
||||||
|
#
|
||||||
# this is the small console program "note" (MYSQL version)
|
# this is the small console program "note" (MYSQL version)
|
||||||
# It works similar to some well known GUI note programs,
|
# It works similar to some well known GUI note programs,
|
||||||
# but instead of using X11 it uses the UN*X console.
|
# but instead of using X11 it uses the UN*X console.
|
||||||
@@ -17,6 +40,38 @@
|
|||||||
# note is GPL software.
|
# note is GPL software.
|
||||||
|
|
||||||
use Mysql;
|
use Mysql;
|
||||||
|
use strict;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
sub usage;
|
||||||
|
sub find_editor;
|
||||||
|
sub output;
|
||||||
|
sub C;
|
||||||
|
sub uen;
|
||||||
|
sub ude;
|
||||||
|
sub num_bereich;
|
||||||
|
sub getdate;
|
||||||
|
|
||||||
|
sub new;
|
||||||
|
sub edit;
|
||||||
|
sub del;
|
||||||
|
sub display;
|
||||||
|
sub list;
|
||||||
|
sub help;
|
||||||
|
sub import;
|
||||||
|
|
||||||
|
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, $KEEP_TIMESTAMP,
|
||||||
|
$BORDERC, $BORDER_COLOR, $_BORDERC, $NOTEC, $NOTE_COLOR,
|
||||||
|
$NUMC, $NUM_COLOR, $_NUMC, $_NOTEC, $TIMEC, $TIME_COLOR,
|
||||||
|
$_TIMEC, $TOPICC, $TOPIC_COLOR, $_TOPICC, $SetTitle, $COLOR,
|
||||||
|
$typedef, $MAX_NOTE, $MAX_TIME, @NumBlock, $ALWAYS_EDIT, $HOME,
|
||||||
|
$db, $dbname, $dbhost, $DEFAULTDBNAME, $dbuser, $USER, $dbpasswd,
|
||||||
|
$table, $fnum, $fnote, $fdate, $date
|
||||||
|
);
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# define some default values.
|
# define some default values.
|
||||||
@@ -25,8 +80,7 @@ use Mysql;
|
|||||||
$maxlen = 20;
|
$maxlen = 20;
|
||||||
$timelen = 22;
|
$timelen = 22;
|
||||||
|
|
||||||
$date = `date +%e\".\"%m\".\"%Y\" \"%T`;
|
$date = &getdate;
|
||||||
chomp $date;
|
|
||||||
|
|
||||||
$USER = getlogin || getpwuid($<);
|
$USER = getlogin || getpwuid($<);
|
||||||
chomp $USER;
|
chomp $USER;
|
||||||
@@ -56,27 +110,22 @@ $BORDER_COLOR = "BLACK";
|
|||||||
$NUM_COLOR = "blue";
|
$NUM_COLOR = "blue";
|
||||||
$NOTE_COLOR = "magenta";
|
$NOTE_COLOR = "magenta";
|
||||||
$TIME_COLOR = "black";
|
$TIME_COLOR = "black";
|
||||||
|
$TOPIC_COLOR = "BLACK";
|
||||||
|
|
||||||
|
# Turns Topic Support on
|
||||||
|
$TOPIC = 1;
|
||||||
|
|
||||||
|
# Default topic separator: \
|
||||||
|
$TopicSep = '/';
|
||||||
|
|
||||||
|
$version = "0.7 (mysql database)";
|
||||||
|
|
||||||
|
if($TOPIC)
|
||||||
|
{
|
||||||
|
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||||
|
}
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
|
|
||||||
sub usage;
|
|
||||||
sub find_editor;
|
|
||||||
sub output;
|
|
||||||
sub C;
|
|
||||||
sub uen;
|
|
||||||
sub ude;
|
|
||||||
sub num_bereich;
|
|
||||||
|
|
||||||
sub new;
|
|
||||||
sub edit;
|
|
||||||
sub del;
|
|
||||||
sub display;
|
|
||||||
sub list;
|
|
||||||
sub help;
|
|
||||||
|
|
||||||
|
|
||||||
$version = "0.4 (mysql database)";
|
|
||||||
|
|
||||||
# process command line args
|
# process command line args
|
||||||
if($ARGV[0] eq "")
|
if($ARGV[0] eq "")
|
||||||
{
|
{
|
||||||
@@ -106,12 +155,16 @@ else
|
|||||||
elsif($ARGV[0] eq "-l" || $ARGV[0] eq "--list")
|
elsif($ARGV[0] eq "-l" || $ARGV[0] eq "--list")
|
||||||
{
|
{
|
||||||
$mode = "list";
|
$mode = "list";
|
||||||
|
my @ArgTopics = split /$TopicSep/,$ARGV[1];
|
||||||
|
$CurDepth += $#ArgTopics + 1 if $ARGV[1];
|
||||||
|
$CurTopic = $ArgTopics[$#ArgTopics]; # use the last element everytime...
|
||||||
$ARGV[0] = "";
|
$ARGV[0] = "";
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist")
|
elsif($ARGV[0] eq "-L" || $ARGV[0] eq "--longlist")
|
||||||
{
|
{
|
||||||
$mode = "list";
|
$mode = "list";
|
||||||
$ListType = "LONG";
|
$ListType = "LONG";
|
||||||
|
$CurTopic = $ARGV[1];
|
||||||
$ARGV[0] = "";
|
$ARGV[0] = "";
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-s" || $ARGV[0] eq "--search")
|
elsif($ARGV[0] eq "-s" || $ARGV[0] eq "--search")
|
||||||
@@ -153,10 +206,26 @@ else
|
|||||||
$mode = "dump";
|
$mode = "dump";
|
||||||
$dump_file = $ARGV[1];
|
$dump_file = $ARGV[1];
|
||||||
$ARGV[0] = "";
|
$ARGV[0] = "";
|
||||||
|
if($dump_file eq "")
|
||||||
|
{
|
||||||
|
$dump_file = "note.dump.$$";
|
||||||
|
print "not dumpfile specified, using $dump_file.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq "-I" || $ARGV[0] eq "--Import" || $ARGV[0] eq "--import")
|
||||||
|
{
|
||||||
|
$mode = "import";
|
||||||
|
$dump_file = $ARGV[1];
|
||||||
|
$ARGV[0] = "";
|
||||||
|
if($dump_file eq "")
|
||||||
|
{
|
||||||
|
print "No dumpfile specified.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-v" || $ARGV[0] eq "--version")
|
elsif($ARGV[0] eq "-v" || $ARGV[0] eq "--version")
|
||||||
{
|
{
|
||||||
print "This is note $version from Thomas Linden <tom\@daemon.de>.\n";
|
print "This is note $version by Thomas Linden <tom\@daemon.de>.\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-h" || $ARGV[0] eq "--help")
|
elsif($ARGV[0] eq "-h" || $ARGV[0] eq "--help")
|
||||||
@@ -183,7 +252,7 @@ if(-e $CONF)
|
|||||||
|
|
||||||
|
|
||||||
# Always interactive?
|
# Always interactive?
|
||||||
if($ALWAYS_INT eq "YES")
|
if($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import")
|
||||||
{
|
{
|
||||||
$mode = "interactive";
|
$mode = "interactive";
|
||||||
}
|
}
|
||||||
@@ -198,25 +267,24 @@ $NOTEC = "<$NOTE_COLOR>";
|
|||||||
$_NOTEC = "</$NOTE_COLOR>";
|
$_NOTEC = "</$NOTE_COLOR>";
|
||||||
$TIMEC = "<$TIME_COLOR>";
|
$TIMEC = "<$TIME_COLOR>";
|
||||||
$_TIMEC = "</$TIME_COLOR>";
|
$_TIMEC = "</$TIME_COLOR>";
|
||||||
|
$TOPICC = "<$TOPIC_COLOR>";
|
||||||
$time = `date +%d\".\"%m\".\"%Y\" \"%T`;
|
$_TOPICC = "</$TOPIC_COLOR>";
|
||||||
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!
|
$maxlen += $timelen; # no time will be displayed!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ok, if still here, we got it all, now let's connect to the database
|
# ok, if still here, we got it all, now let's connect to the database
|
||||||
$db = Mysql->connect($dbhost,$dbname,$dbuser,$dbpasswd)
|
$db = Mysql->connect($dbhost,$dbname,$dbuser,$dbpasswd)
|
||||||
or die "ERROR: $Mysql::dberrstr\n";
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# main loop: ###############
|
# main loop: ###############
|
||||||
if($mode eq "display")
|
if($mode eq "display")
|
||||||
{
|
{
|
||||||
@@ -246,6 +314,10 @@ elsif($mode eq "dump")
|
|||||||
{
|
{
|
||||||
&dump;
|
&dump;
|
||||||
}
|
}
|
||||||
|
elsif($mode eq "import")
|
||||||
|
{
|
||||||
|
&import;
|
||||||
|
}
|
||||||
elsif($mode eq "interactive")
|
elsif($mode eq "interactive")
|
||||||
{
|
{
|
||||||
&interactive;
|
&interactive;
|
||||||
@@ -264,6 +336,7 @@ exit(0);
|
|||||||
############################### DISPLAY ##################################
|
############################### DISPLAY ##################################
|
||||||
sub display
|
sub display
|
||||||
{
|
{
|
||||||
|
my($N,$address,$buffer,$n,$t,$match,$note,$time,$num,@row,$res);
|
||||||
# display a certain note
|
# display a certain note
|
||||||
print "\n";
|
print "\n";
|
||||||
&num_bereich; # get @NumBlock from $numer
|
&num_bereich; # get @NumBlock from $numer
|
||||||
@@ -271,7 +344,7 @@ sub display
|
|||||||
{
|
{
|
||||||
$res = $db->query("SELECT $fnote,$fdate FROM $table WHERE $fnum = $N")
|
$res = $db->query("SELECT $fnote,$fdate FROM $table WHERE $fnum = $N")
|
||||||
or die "ERROR: $Mysql::dberrstr\n";
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
while(@row = $res->fetchrow)
|
||||||
{
|
{
|
||||||
output($N, $row[0], $row[1], "SINGLE");
|
output($N, $row[0], $row[1], "SINGLE");
|
||||||
print "\n";
|
print "\n";
|
||||||
@@ -286,6 +359,7 @@ sub display
|
|||||||
############################### SEARCH ##################################
|
############################### SEARCH ##################################
|
||||||
sub search
|
sub search
|
||||||
{
|
{
|
||||||
|
my($n,$t,$match,$note,$time,$num,$buffer,@row,$res, $sqlstatement);
|
||||||
$maxlen += $timelen;
|
$maxlen += $timelen;
|
||||||
if($searchstring eq "")
|
if($searchstring eq "")
|
||||||
{
|
{
|
||||||
@@ -317,14 +391,107 @@ sub search
|
|||||||
############################### LIST ##################################
|
############################### LIST ##################################
|
||||||
sub list
|
sub list
|
||||||
{
|
{
|
||||||
|
my(@topic,@RealTopic, $i,$buffer,$t,$n,$num,$note,$time,@CurItem,$top,$in, $res, @row);
|
||||||
|
if($mode ne "interactive")
|
||||||
|
{
|
||||||
|
print "List of all existing notes:\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
# list all available notes (number and firstline)
|
# list all available notes (number and firstline)
|
||||||
$res = $db->query("SELECT $fnum,$fnote,$fdate FROM $table ORDER BY $fnum")
|
$res = $db->query("SELECT $fnum,$fnote,$fdate FROM $table ORDER BY $fnum")
|
||||||
or die "ERROR: $Mysql::dberrstr\n";
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
while(@row = $res->fetchrow)
|
if($TOPIC)
|
||||||
{
|
{
|
||||||
output($row[0], $row[1], $row[2]);
|
undef %TP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(@row = $res->fetchrow)
|
||||||
|
{
|
||||||
|
#output($row[0], $row[1], $row[2]);
|
||||||
|
$num = $row[0]; $n = $row[1]; $t = $row[2];
|
||||||
|
if($TOPIC)
|
||||||
|
{
|
||||||
|
# this allows us to have multiple topics (subtopics!)
|
||||||
|
my ($firstline,$dummy) = split /\n/, $n, 2;
|
||||||
|
if($firstline =~ /^($TopicSep)/)
|
||||||
|
{
|
||||||
|
@topic = split(/$TopicSep/,$firstline);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@topic = ();
|
||||||
|
}
|
||||||
|
# looks like: "\topic\"
|
||||||
|
# collect a list of topics under the current topic
|
||||||
|
if($topic[$CurDepth-1] eq $CurTopic && $topic[$CurDepth] ne "")
|
||||||
|
{
|
||||||
|
if(exists $TP{$topic[$CurDepth]})
|
||||||
|
{
|
||||||
|
$TP{$topic[$CurDepth]}++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# only if the next item *is* a topic!
|
||||||
|
$TP{$topic[$CurDepth]} = 1 if(($CurDepth) <= $#topic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($topic[$CurDepth-1] eq $CurTopic || ($topic[$CurDepth] eq "" && $CurDepth ==1))
|
||||||
|
{
|
||||||
|
# cut the topic off the note-text
|
||||||
|
if($n =~ /^($TopicSep)/)
|
||||||
|
{
|
||||||
|
$CurItem[$i]->{'note'} = $dummy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$CurItem[$i]->{'note'} = $n;
|
||||||
|
}
|
||||||
|
# save for later output() call
|
||||||
|
$CurItem[$i]->{'num'} = $num;
|
||||||
|
$CurItem[$i]->{'time'} = $t;
|
||||||
|
$i++;
|
||||||
|
# use this note for building the $PATH!
|
||||||
|
if($RealTopic[0] eq "")
|
||||||
|
{
|
||||||
|
@RealTopic = @topic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output($num, $n, $t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($TOPIC)
|
||||||
|
{
|
||||||
|
if($CurTopic ne "")
|
||||||
|
{
|
||||||
|
undef $PATH;
|
||||||
|
foreach (@RealTopic)
|
||||||
|
{
|
||||||
|
$PATH .= $_ . $TopicSep;
|
||||||
|
last if($_ eq $CurTopic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$PATH = $TopicSep;
|
||||||
|
}
|
||||||
|
|
||||||
|
# we are at top level, print a list of topics...
|
||||||
|
foreach $top (sort(keys %TP))
|
||||||
|
{
|
||||||
|
output("-", " => ". $top . "$TopicSep ($TP{$top} notes)",
|
||||||
|
" Sub Topic ");
|
||||||
|
}
|
||||||
|
#print Dumper(@CurItem);
|
||||||
|
for($in=0;$in<$i;$in++)
|
||||||
|
{
|
||||||
|
output( $CurItem[$in]->{'num'},
|
||||||
|
$CurItem[$in]->{'note'},
|
||||||
|
$CurItem[$in]->{'time'} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
@@ -332,6 +499,8 @@ sub list
|
|||||||
############################### NEW ##################################
|
############################### NEW ##################################
|
||||||
sub new
|
sub new
|
||||||
{
|
{
|
||||||
|
my($TEMP,$editor, $time, $note, $WARN, $c, $line, $num, $te, $me, $buff,$buffer, @topic,$n,$t,$res, @row,$sqlstatement);
|
||||||
|
$time = &getdate;
|
||||||
if($ALWAYS_EDIT eq "YES")
|
if($ALWAYS_EDIT eq "YES")
|
||||||
{
|
{
|
||||||
$TEMP = "/tmp/note.$$";
|
$TEMP = "/tmp/note.$$";
|
||||||
@@ -348,11 +517,18 @@ sub new
|
|||||||
}
|
}
|
||||||
# read it in ($note)
|
# read it in ($note)
|
||||||
$note = "";
|
$note = "";
|
||||||
open E, "<$TEMP" or die "Could not open $TEMP\n";
|
#open E, "<$TEMP" or die "Could not open $TEMP\n";
|
||||||
|
open E, "<$TEMP" or $WARN = 1;
|
||||||
|
if($WARN)
|
||||||
|
{
|
||||||
|
print "...edit process interupted! No note has been saved.\n";
|
||||||
|
undef $WARN;
|
||||||
|
return;
|
||||||
|
}
|
||||||
$c = 0;
|
$c = 0;
|
||||||
while(<E>)
|
while(<E>)
|
||||||
{
|
{
|
||||||
$_ =~ s/'/\\'/g;
|
$_ =~ s/'/`/g;
|
||||||
$note = $note . $_;
|
$note = $note . $_;
|
||||||
}
|
}
|
||||||
chomp $note;
|
chomp $note;
|
||||||
@@ -363,8 +539,8 @@ sub new
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$note = "";
|
$note = "";
|
||||||
local $line = "";
|
$line = "";
|
||||||
#local $num = 0;
|
#$num = 0;
|
||||||
# create a new note
|
# create a new note
|
||||||
print "enter the text of the note, end with .\n";
|
print "enter the text of the note, end with .\n";
|
||||||
do
|
do
|
||||||
@@ -385,8 +561,19 @@ sub new
|
|||||||
$number = $row[0];
|
$number = $row[0];
|
||||||
}
|
}
|
||||||
$number++;
|
$number++;
|
||||||
$sqlstatement = "INSERT INTO $table VALUES (0,$number,'$note','$date')";
|
if($TOPIC && $CurTopic ne "")
|
||||||
|
{
|
||||||
|
@topic = split(/$TopicSep/,$note);
|
||||||
|
if($topic[1] eq "")
|
||||||
|
{
|
||||||
|
$note = $PATH . "\n$note";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# mask all occuring \'s
|
||||||
|
$note =~ s/\\/\\\\/g;
|
||||||
|
|
||||||
|
$sqlstatement = "INSERT INTO $table VALUES ($number,'$note','$date')";
|
||||||
$db->query($sqlstatement)
|
$db->query($sqlstatement)
|
||||||
or die "ERROR: $Mysql::dberrstr\n";
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
|
||||||
@@ -398,27 +585,28 @@ sub new
|
|||||||
############################### DELETE ##################################
|
############################### DELETE ##################################
|
||||||
sub del
|
sub del
|
||||||
{
|
{
|
||||||
|
my($i,@count, $setnum, $buff, %Merk, $num, $note, $pos, $droped, $buffer, $sqlstatement,$res, @row, $ERR);
|
||||||
# delete a note
|
# delete a note
|
||||||
&num_bereich; # get @NumBlock from $number
|
&num_bereich; # get @NumBlock from $number
|
||||||
|
|
||||||
foreach $N (@NumBlock)
|
foreach $_ (@NumBlock)
|
||||||
{
|
{
|
||||||
$sqlstatement = "DELETE FROM $table WHERE $fnum = $N";
|
$sqlstatement = "DELETE FROM $table WHERE $fnum = $_";
|
||||||
$res = $db->query($sqlstatement) or $ERR = $Mysql::dberrstr;
|
$res = $db->query($sqlstatement) or $ERR = $Mysql::dberrstr;
|
||||||
# do not exit if an error occurs - good for int mode!
|
# do not exit if an error occurs - good for int mode!
|
||||||
if($ERR)
|
if($ERR)
|
||||||
{
|
{
|
||||||
print "no note with number $N found!\n";
|
print "no note with number $_ found!\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "note number $N has been deleted.\n";
|
print "note number $_ has been deleted.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# recount the notenumbers:
|
# recount the notenumbers:
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
$sqlstatement = "SELECT id FROM $table ORDER BY id";
|
$sqlstatement = "SELECT $fnum FROM $table ORDER BY $fnum";
|
||||||
$res = $db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
$res = $db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
||||||
while(@row = $res->fetchrow)
|
while(@row = $res->fetchrow)
|
||||||
{
|
{
|
||||||
@@ -429,7 +617,7 @@ sub del
|
|||||||
for($pos=0;$pos<$i;$pos++)
|
for($pos=0;$pos<$i;$pos++)
|
||||||
{
|
{
|
||||||
$setnum = $pos +1;
|
$setnum = $pos +1;
|
||||||
$sqlstatement = "UPDATE $table SET $fnum = '$setnum' WHERE id = $count[$pos]";
|
$sqlstatement = "UPDATE $table SET $fnum = '$setnum' WHERE $fnum = $count[$pos]";
|
||||||
$db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
$db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,12 +625,15 @@ sub del
|
|||||||
############################### EDIT ##################################
|
############################### EDIT ##################################
|
||||||
sub edit
|
sub edit
|
||||||
{
|
{
|
||||||
|
my($keeptime, $time, $editor, $TEMP, $address, $n, $buff, $c, $note, $t, $buffer, $num, $sqlstatement, $res, @row, $match);
|
||||||
# edit a note
|
# edit a note
|
||||||
$sqlstatement = "SELECT $fnote FROM $table WHERE $fnum = $number";
|
$time = &getdate;
|
||||||
|
$sqlstatement = "SELECT $fnote, $fdate FROM $table WHERE $fnum = $number";
|
||||||
$res = $db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
$res = $db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
||||||
while(@row = $res->fetchrow)
|
while(@row = $res->fetchrow)
|
||||||
{
|
{
|
||||||
$note = $row[0];
|
$note = $row[0];
|
||||||
|
$keeptime = $row[1];
|
||||||
$match = "yes";
|
$match = "yes";
|
||||||
}
|
}
|
||||||
if($match eq "")
|
if($match eq "")
|
||||||
@@ -472,7 +663,7 @@ sub edit
|
|||||||
$c = 0;
|
$c = 0;
|
||||||
while(<NOTE>)
|
while(<NOTE>)
|
||||||
{
|
{
|
||||||
$_ =~ s/'/\\'/g;
|
$_ =~ s/'/`/g;
|
||||||
$note = $note . $_;
|
$note = $note . $_;
|
||||||
}
|
}
|
||||||
chomp $note;
|
chomp $note;
|
||||||
@@ -480,9 +671,22 @@ sub edit
|
|||||||
|
|
||||||
system "/bin/rm -f $TEMP";
|
system "/bin/rm -f $TEMP";
|
||||||
|
|
||||||
|
# mask all occuring \'s
|
||||||
|
$note =~ s/\\/\\\\/g;
|
||||||
|
|
||||||
|
if($KEEP_TIMESTAMP eq "YES")
|
||||||
|
{
|
||||||
|
$t = $keeptime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$t = $time;
|
||||||
|
}
|
||||||
|
|
||||||
# we got it, now save to db
|
# we got it, now save to db
|
||||||
$sqlstatement = "UPDATE $table SET "
|
$sqlstatement = "UPDATE $table SET "
|
||||||
. "$fnote = '$note' "
|
. "$fnote = '$note', "
|
||||||
|
. "$fdate = '$t' "
|
||||||
. "WHERE $fnum = $number";
|
. "WHERE $fnum = $number";
|
||||||
$db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
$db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
|
||||||
@@ -492,19 +696,17 @@ sub edit
|
|||||||
|
|
||||||
sub dump
|
sub dump
|
||||||
{
|
{
|
||||||
|
my($buffer,$num, $note, $time,$n, $t, $res, @row);
|
||||||
# $dump_file
|
# $dump_file
|
||||||
open (DUMP, ">$dump_file") or die "could not open $dump_file\n";
|
open (DUMP, ">$dump_file") or die "could not open $dump_file\n";
|
||||||
select DUMP;
|
select DUMP;
|
||||||
$res = $db->query("SELECT $fnum,$fnote,$fdate FROM $table ORDER BY $fnum")
|
$res = $db->query("SELECT $fnum,$fnote,$fdate FROM $table ORDER BY $fnum")
|
||||||
or die "ERROR: $Mysql::dberrstr\n";
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
$res = $db->query($sqlstatement) or die "ERROR: $Mysql::dberrstr\n";
|
|
||||||
|
|
||||||
print "complete dump of note database from $time.\n\n";
|
|
||||||
|
|
||||||
while(@row = $res->fetchrow)
|
while(@row = $res->fetchrow)
|
||||||
{
|
{
|
||||||
print STDOUT "dumping note number $num to $dump_file\n";
|
print STDOUT "dumping note number $row[0] to $dump_file\n";
|
||||||
print "#$num\ttime: $t\nnote:\n$n\n---------\n\n";
|
print "Number: $row[0]\nTimestamp: $row[2]\n$row[1]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -513,46 +715,108 @@ sub dump
|
|||||||
select STDOUT;
|
select STDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub import
|
||||||
|
{
|
||||||
|
my($buff, $num,$te, $me, $start, $complete, $dummi, $n, $t, $buffer, $note, $time, $date);
|
||||||
|
# open $dump_file and import it into the notedb
|
||||||
|
open (DUMP, "<$dump_file") or die "could not open $dump_file\n";
|
||||||
|
$complete=0;
|
||||||
|
$start = 0;
|
||||||
|
while(<DUMP>)
|
||||||
|
{
|
||||||
|
chomp $_;
|
||||||
|
if($_ =~ /^Number:\s\d+/)
|
||||||
|
{
|
||||||
|
if($start == 0)
|
||||||
|
{
|
||||||
|
# we have no previous record
|
||||||
|
($dummi,$number) = split(/\s/,$_);
|
||||||
|
$start = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# we got a complete record, save it!
|
||||||
|
$db->query("INSERT INTO $table VALUES (0,'$note','$date')")
|
||||||
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
print "note number $number from $dump_file inserted into notedb.\n";
|
||||||
|
$complete = 0; # restet $complete
|
||||||
|
$note = ""; # reset $note
|
||||||
|
$date = ""; # reset $date
|
||||||
|
($dummi,$number) = split(/\s/,$_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($_ =~ /^Timestamp:\s\d+/ && $complete == 0)
|
||||||
|
{
|
||||||
|
($dummi,$date,$time) = split(/\s/,$_);
|
||||||
|
$date = "$date $time";
|
||||||
|
$complete = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$note .= $_ . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($note ne "" && $date ne "")
|
||||||
|
{
|
||||||
|
# the last record, if existent
|
||||||
|
$db->query("INSERT INTO $table VALUES (0,'$note','$date')")
|
||||||
|
or die "ERROR: $Mysql::dberrstr\n";
|
||||||
|
print "note number $number from $dump_file inserted into notedb.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub interactive
|
sub interactive
|
||||||
{
|
{
|
||||||
|
my($maxlen_save, $B, $BB, $menu, $char, @LastTopic);
|
||||||
$maxlen_save = $maxlen;
|
$maxlen_save = $maxlen;
|
||||||
# create menu:
|
# create menu:
|
||||||
local $B = "<blackI>";
|
$B = "<blackI>";
|
||||||
local $BB = "</blackI>";
|
$BB = "</blackI>";
|
||||||
local $menu = "[ " . $B . "L" . $BB . " List "
|
$menu = "[" . $B . "L" . $BB . " List "
|
||||||
. $B . "N" . $BB . " New "
|
. $B . "N" . $BB . " New "
|
||||||
. $B . "D" . $BB . " Delete "
|
. $B . "D" . $BB . " Delete "
|
||||||
. $B . "S" . $BB . " Search "
|
. $B . "S" . $BB . " Search "
|
||||||
. $B . "E" . $BB . " Edit "
|
. $B . "E" . $BB . " Edit "
|
||||||
. $B . "?" . $BB . " Help "
|
. $B . "?" . $BB . " Help "
|
||||||
. $B . "Q" . $BB . " Quit ] command> ";
|
. $B . "Q" . $BB . " Quit] "; # $CurTopic will be empty if $TOPIC is off!
|
||||||
# per default let's list all the stuff:
|
# per default let's list all the stuff:
|
||||||
|
# Initially do a list command!
|
||||||
|
$maxlen += $timelen;
|
||||||
|
print "\n";
|
||||||
|
&list;
|
||||||
|
undef $SetTitle;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
#&list;
|
$ListType = "";
|
||||||
$maxlen = $maxlen_save;
|
$maxlen = $maxlen_save;
|
||||||
print "\n\n\n";
|
if($CurDepth > 2)
|
||||||
print C $menu;
|
{
|
||||||
|
print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">";
|
||||||
|
}
|
||||||
|
|
||||||
# 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;
|
||||||
$number = $char;
|
$number = $char;
|
||||||
&display;
|
&display;
|
||||||
|
undef $SetTitle;
|
||||||
}
|
}
|
||||||
elsif($char =~ /^n/i)
|
elsif($char =~ /^n$/i)
|
||||||
{
|
{
|
||||||
# create a new one
|
# create a new one
|
||||||
$time = `date +%d\".\"%m\".\"%Y\" \"%T`;
|
|
||||||
chomp $time;
|
|
||||||
&new;
|
&new;
|
||||||
}
|
}
|
||||||
elsif($char =~ /^l/ || $char =~ /^$/)
|
elsif($char =~ /^l$/ || $char =~ /^$/)
|
||||||
{
|
{
|
||||||
# list
|
# list
|
||||||
print "\n";
|
print "\n";
|
||||||
@@ -561,13 +825,14 @@ sub interactive
|
|||||||
&list;
|
&list;
|
||||||
undef $SetTitle;
|
undef $SetTitle;
|
||||||
}
|
}
|
||||||
elsif($char =~ /^L/)
|
elsif($char =~ /^L$/)
|
||||||
{
|
{
|
||||||
$ListType = "LONG";
|
$ListType = "LONG";
|
||||||
|
print "\n";
|
||||||
&list;
|
&list;
|
||||||
undef $SetTitle;
|
undef $SetTitle;
|
||||||
}
|
}
|
||||||
elsif($char =~ /^h/i || $char =~ /^\?/)
|
elsif($char =~ /^h$/i || $char =~ /^\?/)
|
||||||
{
|
{
|
||||||
# zu dumm der Mensch ;-)
|
# zu dumm der Mensch ;-)
|
||||||
&help;
|
&help;
|
||||||
@@ -590,8 +855,6 @@ sub interactive
|
|||||||
elsif($char =~ /^e\s+(\d+\-*\,*\d*)/i)
|
elsif($char =~ /^e\s+(\d+\-*\,*\d*)/i)
|
||||||
{
|
{
|
||||||
# edit one!
|
# edit one!
|
||||||
$time = `date +%d\".\"%m\".\"%Y\" \"%T`;
|
|
||||||
chomp $time;
|
|
||||||
$number = $1;
|
$number = $1;
|
||||||
&edit;
|
&edit;
|
||||||
}
|
}
|
||||||
@@ -607,7 +870,6 @@ sub interactive
|
|||||||
elsif($char =~ /^s\s+/i)
|
elsif($char =~ /^s\s+/i)
|
||||||
{
|
{
|
||||||
# she want's to search
|
# she want's to search
|
||||||
#$maxlen += $timelen;
|
|
||||||
$searchstring = $';
|
$searchstring = $';
|
||||||
chomp $searchstring;
|
chomp $searchstring;
|
||||||
&search;
|
&search;
|
||||||
@@ -615,7 +877,6 @@ sub interactive
|
|||||||
elsif($char =~ /^s$/i)
|
elsif($char =~ /^s$/i)
|
||||||
{
|
{
|
||||||
# we have to ask her:
|
# we have to ask her:
|
||||||
#$maxlen += $timelen;
|
|
||||||
print "enter the string you want to search for: ";
|
print "enter the string you want to search for: ";
|
||||||
$char = <STDIN>;
|
$char = <STDIN>;
|
||||||
chomp $char;
|
chomp $char;
|
||||||
@@ -623,17 +884,43 @@ sub interactive
|
|||||||
$searchstring = $char;
|
$searchstring = $char;
|
||||||
&search;
|
&search;
|
||||||
}
|
}
|
||||||
elsif($char =~ /^q/i)
|
elsif($char =~ /^q$/i)
|
||||||
{
|
{
|
||||||
# schade!!!
|
# schade!!!
|
||||||
print "\n\ngood bye\n";
|
print "\n\ngood bye\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/)
|
||||||
|
{
|
||||||
|
$CurDepth-- if ($CurDepth > 1);
|
||||||
|
$CurTopic = $LastTopic[$CurDepth];
|
||||||
|
$maxlen += $timelen;
|
||||||
|
print "\n";
|
||||||
|
&list;
|
||||||
|
undef $SetTitle;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# unknown
|
# unknown
|
||||||
|
my $unchar = $char;
|
||||||
|
$unchar =~ s/^cd //; # you may use cd <topic> now!
|
||||||
|
if(exists $TP{$char})
|
||||||
|
{
|
||||||
|
$char = $unchar if(exists $TP{$unchar});
|
||||||
|
$LastTopic[$CurDepth] = $CurTopic;
|
||||||
|
$CurTopic = $char;
|
||||||
|
$maxlen += $timelen;
|
||||||
|
$CurDepth++;
|
||||||
|
print "\n";
|
||||||
|
&list;
|
||||||
|
undef $SetTitle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print "\nunknown command!\n";
|
print "\nunknown command!\n";
|
||||||
}
|
}
|
||||||
|
undef $unchar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,17 +928,23 @@ sub interactive
|
|||||||
|
|
||||||
sub usage
|
sub usage
|
||||||
{
|
{
|
||||||
print qq~
|
print qq~This is the program note $version by Thomas Linden (c) 1999-2000.
|
||||||
usage: note [-i | --interactive] | [ options ] [ number [,number...]]
|
It comes with absolutely NO WARRANTY. It is distributed under the
|
||||||
|
terms of the GNU General Public License. Use it at your own risk :-)
|
||||||
|
Usage: note [-i | --interactive] | [ options ] [ number [,number...]]
|
||||||
Options:
|
Options:
|
||||||
-h --help displays this help screen
|
-h --help displays this help screen
|
||||||
-v --version displays the version number
|
-v --version displays the version number
|
||||||
-l --list lists all existing notes
|
-l --list [<topic>] lists all existing notes If no topic were specified,
|
||||||
-L --longlist the same as -l but prints also the timestamp
|
it will display a list of all existing topics.
|
||||||
|
-L --longlist [<topic>] the same as -l but prints also the timestamp
|
||||||
-s --search <string> searches for <string> trough the notes database
|
-s --search <string> searches for <string> trough the notes database
|
||||||
-e --edit <number> edit note with <number>
|
-e --edit <number> edit note with <number>
|
||||||
-d --delete <number> delete note with <number>
|
-d --delete <number> delete note with <number>
|
||||||
-D --Dump <file> dumps the notes to the textfile <file>
|
-D --Dump [<file>] dumps the notes to the textfile <file>
|
||||||
|
-I --Import <file> imports a previously dumped textfile into the
|
||||||
|
note-database. Dumps from the mysql and the binary
|
||||||
|
version are in the same format.
|
||||||
-i --interactive interactive mode
|
-i --interactive interactive mode
|
||||||
|
|
||||||
o if you specify only a number (i.e. "note 4"), then the note with that
|
o if you specify only a number (i.e. "note 4"), then the note with that
|
||||||
@@ -664,18 +957,17 @@ Options:
|
|||||||
informations about the configuration.
|
informations about the configuration.
|
||||||
o In interactive mode you can get help at any time by typing "?" or "h" at
|
o In interactive mode you can get help at any time by typing "?" or "h" at
|
||||||
the prompt.
|
the prompt.
|
||||||
|
|
||||||
This is the program note $version by Thomas Linden (c) 1999-2000. GPL.
|
|
||||||
|
|
||||||
~;
|
~;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
sub find_editor {
|
sub find_editor {
|
||||||
return $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vim" || "vi" || "pico";
|
return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vim" || "vi" || "pico";
|
||||||
}
|
}
|
||||||
|
#/
|
||||||
sub output
|
sub output
|
||||||
{
|
{
|
||||||
|
my($SSS, $LINE, $num, $note, $time, $TYPE, $L, $LONGSPC, $R, $PathLen, $SP, $title, $CUTSPACE,
|
||||||
|
$len, $diff, $Space);
|
||||||
# 0 = Num, 1 = Note, 2 = Time
|
# 0 = Num, 1 = Note, 2 = Time
|
||||||
if($ListType ne "LONG")
|
if($ListType ne "LONG")
|
||||||
{
|
{
|
||||||
@@ -685,27 +977,28 @@ sub output
|
|||||||
{
|
{
|
||||||
$SSS = "-" x ($maxlen + 31);
|
$SSS = "-" x ($maxlen + 31);
|
||||||
}
|
}
|
||||||
local $LINE = "$BORDERC $SSS $_BORDERC\n";
|
$LINE = "$BORDERC $SSS $_BORDERC\n";
|
||||||
local $num = $_[0];
|
$num = $_[0];
|
||||||
local $note = $_[1];
|
$note = $_[1];
|
||||||
local $time = $_[2];
|
$time = $_[2];
|
||||||
local $TYPE = $_[3];
|
$TYPE = $_[3];
|
||||||
local $L = $BORDERC . "[" . $_BORDERC;
|
$L = $BORDERC . "[" . $_BORDERC;
|
||||||
local $LONGSPC = " " x (22 + 3);
|
$LONGSPC = " " x (22 + 3);
|
||||||
local $R = $BORDERC . "]" . $_BORDERC;
|
$R = $BORDERC . "]" . $_BORDERC;
|
||||||
|
$PathLen = length($PATH); # will be ZERO, if not in TOPIC mode!
|
||||||
if($TYPE ne "SINGLE")
|
if($TYPE ne "SINGLE")
|
||||||
{
|
{
|
||||||
if(!$SetTitle)
|
if(!$SetTitle)
|
||||||
{
|
{
|
||||||
local $SP = "";
|
$SP = "";
|
||||||
# print only if it is the first line!
|
# print only if it is the first line!
|
||||||
if($ListType ne "LONG")
|
if($ListType ne "LONG")
|
||||||
{
|
{
|
||||||
$SP = " " x ($maxlen-2 - $timelen);
|
$SP = " " x ($maxlen-2 - $timelen - $PathLen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$SP = " " x ($maxlen-2);
|
$SP = " " x ($maxlen-2 - $PathLen);
|
||||||
}
|
}
|
||||||
print C $LINE;
|
print C $LINE;
|
||||||
|
|
||||||
@@ -718,22 +1011,36 @@ sub output
|
|||||||
{
|
{
|
||||||
print $LONGSPC;
|
print $LONGSPC;
|
||||||
}
|
}
|
||||||
|
if($TOPIC)
|
||||||
|
{
|
||||||
|
print C $TOPICC . "$PATH $_TOPICC$SP$R\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print C $NOTEC . "note$_NOTEC$SP$R\n";
|
print C $NOTEC . "note$_NOTEC$SP$R\n";
|
||||||
|
}
|
||||||
|
|
||||||
print C $LINE;
|
print C $LINE;
|
||||||
$SetTitle = 1;
|
$SetTitle = 1;
|
||||||
}
|
}
|
||||||
local $title = "";
|
$title = "";
|
||||||
$CUTSPACE = " " x $maxlen;
|
$CUTSPACE = " " x $maxlen;
|
||||||
$note =~ s/\n/$CUTSPACE/g;
|
$note =~ s/\n/$CUTSPACE/g;
|
||||||
local $len = length($note);
|
$len = length($note);
|
||||||
if($len < $maxlen-3)
|
if($len < $maxlen-3)
|
||||||
{
|
{
|
||||||
local $diff = $maxlen - $len;
|
$diff = $maxlen - $len;
|
||||||
local $Space = " " x $diff;
|
$Space = " " x $diff;
|
||||||
|
if($num eq "-")
|
||||||
|
{
|
||||||
|
$title = $BORDERC . $TOPICC . "\"" . $note . "\"" . $_TOPICC . $Space . "$_BORDERC";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$title = $BORDERC . $NOTEC . "\"" . $note . "\"" . $_NOTEC . $Space . "$_BORDERC";
|
$title = $BORDERC . $NOTEC . "\"" . $note . "\"" . $_NOTEC . $Space . "$_BORDERC";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$title = substr($note,0,$maxlen - 3);
|
$title = substr($note,0,$maxlen - 3);
|
||||||
@@ -753,8 +1060,8 @@ sub output
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
chomp $note;
|
chomp $note;
|
||||||
local $Space = " " x ($maxlen - 16);
|
$Space = " " x ($maxlen - 16);
|
||||||
local $SP = " " x ($maxlen + 13);
|
$SP = " " x ($maxlen + 13);
|
||||||
#print C $LINE;
|
#print C $LINE;
|
||||||
#print C "$L $NUMC#$_NUMC " . $TIMEC . "creation date$_TIMEC$SP$R\n";
|
#print C "$L $NUMC#$_NUMC " . $TIMEC . "creation date$_TIMEC$SP$R\n";
|
||||||
print C $LINE;
|
print C $LINE;
|
||||||
@@ -770,8 +1077,9 @@ sub output
|
|||||||
|
|
||||||
sub C
|
sub C
|
||||||
{
|
{
|
||||||
|
my(%Color, $default, $S, $Col, $NC, $T);
|
||||||
# \033[1m%30s\033[0m
|
# \033[1m%30s\033[0m
|
||||||
local %Color = ( 'black' => '0;30',
|
%Color = ( 'black' => '0;30',
|
||||||
'red' => '0;31',
|
'red' => '0;31',
|
||||||
'green' => '0;32',
|
'green' => '0;32',
|
||||||
'yellow' => '0;33',
|
'yellow' => '0;33',
|
||||||
@@ -830,22 +1138,25 @@ sub C
|
|||||||
|
|
||||||
sub uen
|
sub uen
|
||||||
{
|
{
|
||||||
local $T = pack("u", $_[0]);
|
my($T);
|
||||||
|
$T = pack("u", $_[0]);
|
||||||
chomp $T;
|
chomp $T;
|
||||||
return $T;
|
return $T;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ude
|
sub ude
|
||||||
{
|
{
|
||||||
local $T = unpack("u", $_[0]);
|
my($T);
|
||||||
|
$T = unpack("u", $_[0]);
|
||||||
return $T;
|
return $T;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub num_bereich
|
sub num_bereich
|
||||||
{
|
{
|
||||||
|
my($m,@LR,@Sorted_LR,$i);
|
||||||
# $number is the one we want to delete!
|
# $number is the one we want to delete!
|
||||||
# But does it contain kommas?
|
# But does it contain kommas?
|
||||||
local $m = 0;
|
$m = 0;
|
||||||
if($number =~ /\,/)
|
if($number =~ /\,/)
|
||||||
{
|
{
|
||||||
# accept -d 3,4,7
|
# accept -d 3,4,7
|
||||||
@@ -854,8 +1165,23 @@ sub num_bereich
|
|||||||
elsif($number =~ /^\d+\-\d+$/)
|
elsif($number =~ /^\d+\-\d+$/)
|
||||||
{
|
{
|
||||||
# accept -d 3-9
|
# accept -d 3-9
|
||||||
local @LR = split(/\-/,$number);
|
@LR = split(/\-/,$number);
|
||||||
local @Sorted_LR = sort @LR;
|
@Sorted_LR = ();
|
||||||
|
|
||||||
|
if($LR[0] > $LR[1])
|
||||||
|
{
|
||||||
|
@Sorted_LR = ($LR[1], $LR[0]);
|
||||||
|
}
|
||||||
|
elsif($LR[0] == $LR[1])
|
||||||
|
{
|
||||||
|
# 0 and 1 are the same
|
||||||
|
@Sorted_LR = ($LR[0], $LR[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@Sorted_LR = ($LR[0], $LR[1]);
|
||||||
|
}
|
||||||
|
|
||||||
for($i=$Sorted_LR[0]; $i<=$Sorted_LR[1]; $i++)
|
for($i=$Sorted_LR[0]; $i<=$Sorted_LR[1]; $i++)
|
||||||
{
|
{
|
||||||
# from 3-6 create @NumBlock (3,4,5,6)
|
# from 3-6 create @NumBlock (3,4,5,6)
|
||||||
@@ -870,6 +1196,19 @@ sub num_bereich
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub getdate
|
||||||
|
{
|
||||||
|
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||||
|
$year += 1900;
|
||||||
|
$mon += 1;
|
||||||
|
$mon =~ s/^(\d)$/0$1/;
|
||||||
|
$hour =~ s/^(\d)$/0$1/;
|
||||||
|
$min =~ s/^(\d)$/0$1/;
|
||||||
|
$sec =~ s/^(\d)$/0$1/;
|
||||||
|
$mday =~ s/^(\d)$/0$1/;
|
||||||
|
return "$mday.$mon.$year $hour:$min:$sec";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub help
|
sub help
|
||||||
{
|
{
|
||||||
@@ -878,16 +1217,26 @@ print qq~
|
|||||||
HELP for interactive note $version
|
HELP for interactive note $version
|
||||||
|
|
||||||
The following commands are available:
|
The following commands are available:
|
||||||
L/l List notes. L=long, with timestamp and l=short without
|
L/l List notes. L=long, with timestamp and l=short without timestamp.
|
||||||
timestamp. You can also just hit <enter> for short list.
|
You can also just hit <enter> for short list.
|
||||||
N Create a new note.
|
N Create a new note.
|
||||||
D Delete a note. You can either hit "d 1" or "d 1-4"
|
D Delete a note. You can either hit "d 1" or "d 1-4" or just hit "d".
|
||||||
or just hit "d". If you don't specify a number, you
|
If you don't specify a number, you will be asked for.
|
||||||
will be asked for.
|
S Search trough the notes database. Usage is similar to Delete, use
|
||||||
S Search trough the notes database. Usage is similar to
|
a string instead of a number to search for.
|
||||||
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
|
||||||
E Edit a note. Usage is similar to Delete but you can
|
a time.~;
|
||||||
only edit one 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.
|
?/H This help screen.
|
||||||
Q Exit the program.
|
Q Exit the program.
|
||||||
|
|
||||||
@@ -895,7 +1244,3 @@ All commands except the List command are case insensitive.
|
|||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
~;
|
~;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user