mirror of
https://codeberg.org/scip/note.git
synced 2025-12-17 04:31:02 +01:00
FIXED: the T (and t respectively) printed nothing out since 1.0.3! It does
it now again...
ADDED: a new database backend added, NOTEDB::dbm, which uses DBM files for
storage.
FIXED: &display-tree returns now, if there is no note, otherwise it
would die because of an undefined refernce.
CHANGED: Changed the config file format completely. It is now no more a perl
file, instead it is a simple plain text file which note parses.
CHANGED: Changed the way, note loads it database backend. It uses now the
$dbdriver variable as module-name, which makes it possible easily
to write your own backend without the need to change note itself.
FIXED: Removed Getopt::Long option "bundling", causes errors with perl
5.6.0 and is not senceful.
FIXED: Added the Getopt::Long option "no_ignore_case". In 1.0.4 options
were case insensitive causing -i to be interpreted as --import
instead of --interactive ;-(((
ADDED: a new config option $DEFAULT_LIST, which causes note, \
if turned to "LONG", to use long-listing as default. |
But it will still be able to use short-listing if you |
explicit specify that. | submitted by
FIXED: sub search prints now an appropriate error-message in |==> Peter Palmreuther
case no searchstring was given instead of jumping to | thanks a lot!
usage. |
CHANGED: Changed the text in the interactive help to reflect |
changes of verion 1.0.3 (t and T). /
This commit is contained in:
516
bin/note
516
bin/note
@@ -1,191 +1,164 @@
|
||||
#!/usr/bin/perl
|
||||
# $Author: thomas $ $Id: note,v 1.24 2000/05/10 22:59:44 thomas Exp thomas $ $Revision: 1.24 $
|
||||
# $Id: note,v 1.26 2000/05/13 01:05:17 thomas Exp thomas $
|
||||
#
|
||||
# $Log: note,v $
|
||||
# Revision 1.24 2000/05/10 22:59:44 thomas
|
||||
# updated usage to reflect --raw and build it into output
|
||||
# and display subs.
|
||||
#
|
||||
# Revision 1.23 2000/05/10 22:19:04 thomas
|
||||
# changed to Getopt::Long, added --raw
|
||||
# note - console notes management with database and encryption support.
|
||||
# Copyright (C) 1999-2000 Thomas Linden (see README for details!)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# Revision 1.22 2000/05/01 18:51:40 thomas
|
||||
# added "-" to sub dump
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Revision 1.21 2000/05/01 00:17:27 thomas
|
||||
# *** empty log message ***
|
||||
# - Thomas Linden <tom@daemon.de>
|
||||
#
|
||||
# Revision 1.20 2000/04/30 23:31:38 thomas
|
||||
# added -o and coloured sub help.
|
||||
# latest version on:
|
||||
# http://www.daemon.de/software.html
|
||||
# ftp://www.0x49.org/pub/scip/note/
|
||||
#
|
||||
# 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() !
|
||||
#
|
||||
# Revision 1.14 2000/03/19 22:51:49 thomas
|
||||
# Bug in NOTEDB::binary fixed, recount of nubers was
|
||||
# incorrect.
|
||||
#
|
||||
# Revision 1.13 2000/03/19 11:53:32 thomas
|
||||
# edit bug fixed (ude => uen)
|
||||
#
|
||||
# Revision 1.12 2000/03/19 03:06:51 thomas
|
||||
# backend support completed.
|
||||
# mysql and binary backends now excluded in separate files
|
||||
#
|
||||
# Revision 1.11 2000/03/18 00:16:47 thomas
|
||||
# added NOTEDB::mysql and changed note to work with that.
|
||||
# thus, from now on there is only one script to maintain and
|
||||
# it is possible to provide more bacjends as well as making
|
||||
# additional scripts upon them, i.e. cgi script...
|
||||
#
|
||||
# Revision 1.8 2000/03/13 22:48:43 thomas
|
||||
# small width bug fixed
|
||||
#
|
||||
# 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"
|
||||
# It works similar to some well known GUI note programs,
|
||||
# but instead of using X11 it uses the UN*X console.
|
||||
# You can edit existing notes, delete them, create new
|
||||
# ones and, of course display them.
|
||||
# The notes will be stored in a mysql database. Refer to
|
||||
# the README of the desitribution for details about
|
||||
# installation.
|
||||
# It requires a configfile named .noterc in the users home.
|
||||
# If it does not exist, note will create one for you, which
|
||||
# you will have to edit.
|
||||
#
|
||||
# If you find it usefull or find a bug, please let me know:
|
||||
# Thomas Linden <tom@daemon.de>
|
||||
#
|
||||
# note is GPL software.
|
||||
|
||||
use strict;
|
||||
#use Data::Dumper;
|
||||
use Getopt::Long;
|
||||
|
||||
sub usage;
|
||||
sub find_editor;
|
||||
sub output;
|
||||
sub C;
|
||||
sub uen;
|
||||
sub ude;
|
||||
sub num_bereich;
|
||||
sub getdate;
|
||||
#
|
||||
# prototypes
|
||||
#
|
||||
sub usage; # print usage message for us thumb userz :-)
|
||||
sub find_editor; # returns an external editor for use
|
||||
sub output; # used by &list and &display
|
||||
sub C; # print colourized
|
||||
sub num_bereich; # returns array from "1-4" (1,2,3,4)
|
||||
sub getdate; # return pretty formatted day
|
||||
sub new; # crate new note
|
||||
sub edit; # edit a note
|
||||
sub del; # delete a note
|
||||
sub display; # display one or more notes
|
||||
sub list; # note-listing
|
||||
sub help; # interactive help screen
|
||||
sub import; # import from notedb-dump
|
||||
sub display_tree; # show nice tree-view
|
||||
sub tree; # build the tree
|
||||
sub print_tree; # print the tree, contributed by Jens Heunemann <Jens.Heunemann@consol.de>. THX!
|
||||
|
||||
sub new;
|
||||
sub edit;
|
||||
sub del;
|
||||
sub display;
|
||||
sub list;
|
||||
sub help;
|
||||
sub import;
|
||||
sub display_tree;
|
||||
sub tree;
|
||||
sub print_tree;
|
||||
|
||||
#
|
||||
# globals
|
||||
#
|
||||
my (
|
||||
$maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB, $NoteKey, $ImportType, $NewType,
|
||||
$version, $number, $CurTopic, $CurDepth, $PATH, $CONF, $WantTopic,
|
||||
$sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep,
|
||||
$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,
|
||||
$typedef, $MAX_NOTE, $MAX_TIME, @NumBlock, $ALWAYS_EDIT, $HOME, $has_nothing,
|
||||
$db, $dbname, $dbhost, $DEFAULTDBNAME, $dbuser, $USER, $dbpasswd,
|
||||
$table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath, $db, @ArgTopics, $Raw,
|
||||
$USE_CRYPT, $CRYPT_METHOD, $key,
|
||||
$opt_, $opt_i, $opt_r, $opt_e, $opt_d, $opt_s,
|
||||
$opt_t, $opt_T, $opt_l, $opt_L, $opt_D, $opt_I,
|
||||
$opt_o, $opt_h, $opt_n, $opt_v
|
||||
#
|
||||
# commandline options
|
||||
#
|
||||
$opt_, $opt_i, $opt_r, $opt_e, $opt_d,
|
||||
$opt_s, $opt_t, $opt_T, $opt_l, $opt_L,
|
||||
$opt_D, $opt_I, $opt_o, $opt_h, $opt_n, $opt_v,
|
||||
|
||||
#
|
||||
# set from commandline (or interactive)
|
||||
#
|
||||
$number, $searchstring, $dump_file, $ImportType, $NewType, $Raw,
|
||||
|
||||
#
|
||||
# options from config file .noterc
|
||||
#
|
||||
$maxlen, $timelen, $TOPIC, $NOTEDB, $MAX_TIME, $PreferredEditor,
|
||||
$ALWAYS_INT, $KEEP_TIMESTAMP, $COLOR, $ALWAYS_EDIT, $HOME,
|
||||
$BORDER_COLOR, $NOTE_COLOR, $NUM_COLOR, $TOPIC_COLOR, $MAX_NOTE,
|
||||
$USE_CRYPT, $CRYPT_METHOD, $TopicSep, $DEFAULT_LIST, $TIME_COLOR,
|
||||
|
||||
#
|
||||
# db specifics from .noterc
|
||||
#
|
||||
$db, $dbname, $dbhost, $dbuser, $dbpasswd,
|
||||
$table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath,
|
||||
|
||||
#
|
||||
# processed colors
|
||||
#
|
||||
$BORDERC, $_BORDERC, $NOTEC, $NUMC, $_NUMC, $_NOTEC, $TIMEC,
|
||||
$_TIMEC, $TOPICC, $_TOPICC,
|
||||
|
||||
#
|
||||
# config presets
|
||||
#
|
||||
$DEFAULTDBNAME, $USER, $PATH, $CONF,
|
||||
|
||||
#
|
||||
# internals
|
||||
#
|
||||
$TYPE, $mode, $NoteKey,
|
||||
$version, $number, $CurTopic, $CurDepth, $WantTopic,
|
||||
$sizeof, %TP, $TreeType, $ListType, $SetTitle,
|
||||
@ArgTopics, $key, $typedef, @NumBlock, $has_nothing,
|
||||
);
|
||||
|
||||
####################################################################
|
||||
# DEFAULTS, allows one to use note without a config ################
|
||||
# don't change them, instead use the config file! ################
|
||||
####################################################################
|
||||
$maxlen = 30;
|
||||
$timelen = 22;
|
||||
$date = &getdate;
|
||||
$USER = getlogin || getpwuid($<);
|
||||
|
||||
#
|
||||
# DEFAULTS, allows one to use note without a config
|
||||
# don't change them, instead use the config file!
|
||||
#
|
||||
$maxlen = 30;
|
||||
$timelen = 22;
|
||||
$date = &getdate;
|
||||
$USER = getlogin || getpwuid($<);
|
||||
chomp $USER;
|
||||
$HOME = $ENV{'HOME'};
|
||||
$CONF = $HOME . "/.noterc";
|
||||
$dbdriver = "binary";
|
||||
$libpath = "/usr/local/lib";
|
||||
$NOTEDB = $HOME . "/.notedb";
|
||||
$MAX_NOTE = 4096;
|
||||
$MAX_TIME = 64;
|
||||
$COLOR = "YES";
|
||||
$BORDER_COLOR = "BLACK";
|
||||
$NUM_COLOR = "blue";
|
||||
$NOTE_COLOR = "green";
|
||||
$TIME_COLOR = "black";
|
||||
$TOPIC_COLOR = "BLACK";
|
||||
$TOPIC = 1;
|
||||
$TopicSep = '/';
|
||||
$version = "1.0.4";
|
||||
$HOME = $ENV{'HOME'};
|
||||
$CONF = $HOME . "/.noterc";
|
||||
$dbdriver = "binary";
|
||||
$libpath = "/usr/local/lib";
|
||||
$NOTEDB = $HOME . "/.notedb";
|
||||
$MAX_NOTE = 4096;
|
||||
$MAX_TIME = 64;
|
||||
$COLOR = "YES";
|
||||
$BORDER_COLOR = "BLACK";
|
||||
$NUM_COLOR = "blue";
|
||||
$NOTE_COLOR = "green";
|
||||
$TIME_COLOR = "black";
|
||||
$TOPIC_COLOR = "BLACK";
|
||||
$TOPIC = 1;
|
||||
$TopicSep = '/';
|
||||
$version = "1.0.5";
|
||||
if($TOPIC)
|
||||
{
|
||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||
}
|
||||
$USE_CRYPT = "NO";
|
||||
####################################################################
|
||||
$USE_CRYPT = "NO";
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# process command line args
|
||||
#
|
||||
if($ARGV[0] eq "")
|
||||
{
|
||||
$mode = "new";
|
||||
}
|
||||
elsif($#ARGV == 0 && $ARGV[0] eq "-") {
|
||||
$mode = "new";
|
||||
$NewType = 1;
|
||||
$NewType = 1; # read from STDIN until EOF
|
||||
shift;
|
||||
undef $has_nothing;
|
||||
}
|
||||
else
|
||||
{
|
||||
Getopt::Long::Configure( qw(bundling)); # allow -lr
|
||||
Getopt::Long::Configure( qw(no_ignore_case));
|
||||
GetOptions (
|
||||
"interactive|i!" => \$opt_i, # no arg
|
||||
"raw|r!" => \$opt_r, # no arg
|
||||
"edit|e=i" => \$opt_e, # integer, required
|
||||
"delete|d=s" => \$opt_d, # integer, required
|
||||
"search|s=s" => \$opt_s, # string, required
|
||||
"tree|t!" => \$opt_t, # no arg
|
||||
"tree|topic|t!" => \$opt_t, # no arg
|
||||
"long_tree|T!" => \$opt_T, # no arg
|
||||
"list|l:s" => \$opt_l, # string, optional
|
||||
"long_list|L:s" => \$opt_L, # string, optional
|
||||
@@ -198,7 +171,9 @@ else
|
||||
$opt_n = shift; # after that @ARGV contains eventually
|
||||
# a note-number
|
||||
# $opt_ is a single dash, in case of existence!
|
||||
#
|
||||
# determine mode
|
||||
#
|
||||
if($opt_i) {
|
||||
$mode = "interactive";
|
||||
}
|
||||
@@ -305,10 +280,10 @@ if($has_nothing && $mode eq "")
|
||||
}
|
||||
|
||||
|
||||
# open the configfile.
|
||||
# read the configfile.
|
||||
if(-e $CONF)
|
||||
{
|
||||
eval `cat $CONF`;
|
||||
&getconfig($CONF);
|
||||
}
|
||||
|
||||
|
||||
@@ -318,29 +293,40 @@ if($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import")
|
||||
$mode = "interactive";
|
||||
}
|
||||
|
||||
# OK ... Long-Listing shall be default ... You wanted it!!!
|
||||
if($DEFAULT_LIST eq "LONG")
|
||||
{
|
||||
# takes only precedence in commandline mode
|
||||
$ListType="LONG";
|
||||
}
|
||||
|
||||
|
||||
|
||||
# *if* loading of the config was successful, try to load the
|
||||
# configured database backend. Currently supported: mysql and binary.
|
||||
push @INC, $libpath;
|
||||
if($dbdriver eq "mysql") {
|
||||
eval {
|
||||
require NOTEDB::mysql;
|
||||
$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate);
|
||||
}
|
||||
}
|
||||
elsif($dbdriver eq "binary") {
|
||||
#if($dbdriver eq "mysql") {
|
||||
# eval {
|
||||
# require NOTEDB::mysql;
|
||||
# $db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate);
|
||||
# }
|
||||
#}
|
||||
if($dbdriver eq "binary") {
|
||||
eval {
|
||||
require NOTEDB::binary;
|
||||
$db = new NOTEDB($dbdriver, $NOTEDB, $MAX_NOTE, $MAX_TIME, $dbdriver);
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "Unsupported database backend: NOTEDB::$dbdriver!\n";
|
||||
exit 1;
|
||||
eval {
|
||||
require "NOTEDB/$dbdriver.pm";
|
||||
$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate);
|
||||
};
|
||||
}
|
||||
if($@) {
|
||||
print "backend-error: " . $@;
|
||||
exit 1;
|
||||
print "Unsupported database backend: NOTEDB::$dbdriver!\n";
|
||||
print "The following error has occured:\n------------------------\n" . $@ . "\n------------------------\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# add the backend version to the note version:
|
||||
@@ -490,28 +476,28 @@ sub display
|
||||
############################### SEARCH ##################################
|
||||
sub search
|
||||
{
|
||||
my($n,$match,$note,$date,$num,%res);
|
||||
my($n,$match,$note,$date,$num,%res);
|
||||
$maxlen += $timelen;
|
||||
if($searchstring eq "")
|
||||
{
|
||||
&usage;
|
||||
print "No searchstring specified!\n";
|
||||
}
|
||||
print "searching the database $dbname for \"$searchstring\"...\n\n";
|
||||
else {
|
||||
print "searching the database $dbname for \"$searchstring\"...\n\n";
|
||||
|
||||
%res = $db->get_search($searchstring);
|
||||
%res = $db->get_search($searchstring);
|
||||
|
||||
foreach $num (sort { $a <=> $b } keys %res)
|
||||
{
|
||||
output($num, $res{$num}->{'note'}, $res{$num}->{'date'});
|
||||
$match = 1;
|
||||
}
|
||||
|
||||
|
||||
if(!$match)
|
||||
{
|
||||
print "no matching note found!\n";
|
||||
}
|
||||
print "\n";
|
||||
foreach $num (sort { $a <=> $b } keys %res)
|
||||
{
|
||||
output($num, $res{$num}->{'note'}, $res{$num}->{'date'});
|
||||
$match = 1;
|
||||
}
|
||||
if(!$match)
|
||||
{
|
||||
print "no matching note found!\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -872,7 +858,8 @@ sub import
|
||||
|
||||
sub interactive
|
||||
{
|
||||
my($maxlen_save, $B, $BB, $menu, $char, @LastTopic);
|
||||
my($maxlen_save, $B, $BB, $menu, $char, @LastTopic, $Channel);
|
||||
$Channel = $|;
|
||||
$maxlen_save = $maxlen;
|
||||
# create menu:
|
||||
$B = "<blackI>";
|
||||
@@ -889,7 +876,7 @@ sub interactive
|
||||
. $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;
|
||||
$maxlen += $timelen if($DEFAULT_LIST ne "LONG");
|
||||
print "\n";
|
||||
&list;
|
||||
undef $SetTitle;
|
||||
@@ -927,8 +914,13 @@ sub interactive
|
||||
{
|
||||
# list
|
||||
print "\n";
|
||||
$ListType = "";
|
||||
$maxlen += $timelen;
|
||||
if($DEFAULT_LIST eq "LONG" && $char =~ /^$/) {
|
||||
$ListType = "LONG";
|
||||
}
|
||||
else {
|
||||
$ListType = "";
|
||||
$maxlen += $timelen;
|
||||
}
|
||||
&list;
|
||||
undef $SetTitle;
|
||||
}
|
||||
@@ -994,11 +986,13 @@ sub interactive
|
||||
elsif($char =~ /^q$/i)
|
||||
{
|
||||
# schade!!!
|
||||
print "\n\ngood bye\n";
|
||||
$| = $Channel;
|
||||
print "\n\ngood bye!\n";
|
||||
exit(0);
|
||||
}
|
||||
elsif($char =~ /^t$/)
|
||||
{
|
||||
$TreeType = "";
|
||||
&display_tree;
|
||||
}
|
||||
elsif($char =~ /^T$/)
|
||||
@@ -1092,7 +1086,7 @@ Options:
|
||||
which causes note, silently to read in a dump from STDIN.
|
||||
-o --overwrite only suitable for use with --Import. Overwrites an
|
||||
existing notedb.
|
||||
-r --raw raw mode, out will not be formatted. Works not in interactive
|
||||
-r --raw raw mode, output will not be formatted. Works not in interactive
|
||||
mode, only on cmd-line for list and display.
|
||||
-i --interactive interactive mode
|
||||
- if you run note only with one dash: "note -", then it will
|
||||
@@ -1103,8 +1097,8 @@ Options:
|
||||
number will be displayed.
|
||||
o you can specify more then one number for delete and display, for example:
|
||||
"note -d 3,4" deletes #3 and #4. "note 5-7" displays #5, #6 and #7.
|
||||
o if you run note without any parameter and if \$ALWAYS_INT in the config is
|
||||
not set, then note will create a new note and prompt you for new text.
|
||||
o if you run note without any parameter and if "AlwaysInteractive" in the config
|
||||
set off, then note will create a new note and prompt you for new text.
|
||||
o If it finds \~/.noterc, it will process it. Refer to the manpage for more
|
||||
informations about the configuration.
|
||||
o In interactive mode you can get help at any time by typing "?" or "h" at
|
||||
@@ -1308,20 +1302,6 @@ sub C
|
||||
}
|
||||
|
||||
|
||||
sub uen
|
||||
{
|
||||
my($T);
|
||||
$T = pack("u", $_[0]);
|
||||
chomp $T;
|
||||
return $T;
|
||||
}
|
||||
|
||||
sub ude
|
||||
{
|
||||
my($T);
|
||||
$T = unpack("u", $_[0]);
|
||||
return $T;
|
||||
}
|
||||
|
||||
sub num_bereich
|
||||
{
|
||||
@@ -1431,7 +1411,7 @@ $T print a list of all existing topics as a tree. T prints the tree
|
||||
}
|
||||
print C qq~
|
||||
$NOTEC
|
||||
All commands except the List command are case insensitive. $_NOTEC $BORDERC
|
||||
All commands except the List and Topic commands are case insensitive. $_NOTEC $BORDERC
|
||||
----------------------------------------------------------------------$_BORDERC
|
||||
~;
|
||||
}
|
||||
@@ -1459,10 +1439,10 @@ sub display_tree {
|
||||
}
|
||||
&tree($num, $text, \%TREE, @nodes);
|
||||
}
|
||||
|
||||
#return if ($num == 0);
|
||||
# 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_tree(\%{$TREE{''}},"") if(%TREE);
|
||||
print C $BORDERC . $_BORDERC . "\n";
|
||||
}
|
||||
|
||||
@@ -1506,3 +1486,135 @@ sub print_tree {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub getconfig
|
||||
{
|
||||
my($configfile) = @_;
|
||||
my ($home, $value, $option);
|
||||
# checks are already done, so trust myself and just open it!
|
||||
open CONFIG, "<$configfile" || die $!;
|
||||
while(<CONFIG>) {
|
||||
chomp;
|
||||
next if(/^\s*$/ || /^\s*#/);
|
||||
my ($option,$value) = split /\s\s*/, $_, 2;
|
||||
$value =~ s/\s*$//;
|
||||
$home = $value if (/^Home/);
|
||||
$libpath = $value if (/^LibPath/);
|
||||
$dbdriver = $value if (/^DbDriver/);
|
||||
$dbhost = $value if (/^DbHost/);
|
||||
$dbuser = $value if (/^DbUser/);
|
||||
$dbpasswd = $value if (/^DbPasswd/);
|
||||
$dbname = $value if (/^DbName/);
|
||||
$table = $value if (/^DbTable/);
|
||||
$fnum = $value if (/^FieldNumber/);
|
||||
$fnote = $value if (/^FieldNote/);
|
||||
$fdate = $value if (/^FieldDate/);
|
||||
$NOTEDB = $value if (/^NoteDb/);
|
||||
$MAX_NOTE = $value if (/^MaxNoteByte/);
|
||||
$MAX_TIME = $value if (/^MaxTimeByte/);
|
||||
$USE_CRYPT = "YES" if (/^UseEncryption/ && $value == 1);
|
||||
$CRYPT_METHOD = $value if (/^CryptMethod/);
|
||||
$ALWAYS_INT = "YES" if (/^AlwaysInteractive/ && $value == 1);
|
||||
$DEFAULT_LIST = "LONG" if (/^DefaultLong/ && $value == 1);
|
||||
$ALWAYS_EDIT = "YES" if (/^AlwaysEditor/ && $value == 1);
|
||||
$KEEP_TIMESTAMP = "YES" if (/^KeepTimeStamp/ && $value == 1);
|
||||
$TopicSep = $value if (/^TopicSeparator/);
|
||||
$maxlen = $value if (/^MaxLen/);
|
||||
$COLOR = "YES" if (/^UseColors/ && $value == 1);
|
||||
$BORDER_COLOR = $value if (/^BorderColor/);
|
||||
$NUM_COLOR = $value if (/^NumberColor/);
|
||||
$NOTE_COLOR = $value if(/^NoteColor/);
|
||||
$TIME_COLOR = $value if (/^TimeColor/);
|
||||
$TOPIC_COLOR = $value if (/^TopicColor/);
|
||||
}
|
||||
chomp $home;
|
||||
$home =~ s/\/*$//;
|
||||
$HOME = eval($home);
|
||||
if($NOTEDB =~ /^(~\/)(.*)$/) {
|
||||
$NOTEDB = "/home/" . $USER . "/" . $2;
|
||||
}
|
||||
$libpath =~ s/\/*$//;
|
||||
|
||||
close CONFIG;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
__END__
|
||||
#
|
||||
# $Log: note,v $
|
||||
# Revision 1.26 2000/05/13 01:05:17 thomas
|
||||
# changed config format and fixed some bugs
|
||||
# as well as some other additions...
|
||||
#
|
||||
# Revision 1.25 2000/05/11 23:42:43 thomas
|
||||
# --tree changed to --topic
|
||||
#
|
||||
# Revision 1.24 2000/05/10 22:59:44 thomas
|
||||
# updated usage to reflect --raw and build it into output
|
||||
# and display subs.
|
||||
#
|
||||
# Revision 1.23 2000/05/10 22:19:04 thomas
|
||||
# changed to Getopt::Long, added --raw
|
||||
#
|
||||
# Revision 1.22 2000/05/01 18:51:40 thomas
|
||||
# added "-" to sub dump
|
||||
#
|
||||
# Revision 1.21 2000/05/01 00:17:27 thomas
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.20 2000/04/30 23:31:38 thomas
|
||||
# added -o and coloured sub help.
|
||||
#
|
||||
# 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() !
|
||||
# Revision 1.14 2000/03/19 22:51:49 thomas
|
||||
# Bug in NOTEDB::binary fixed, recount of nubers was
|
||||
# incorrect.
|
||||
#
|
||||
# Revision 1.13 2000/03/19 11:53:32 thomas
|
||||
# edit bug fixed (ude => uen)
|
||||
#
|
||||
# Revision 1.12 2000/03/19 03:06:51 thomas
|
||||
# backend support completed.
|
||||
# mysql and binary backends now excluded in separate files
|
||||
#
|
||||
# Revision 1.11 2000/03/18 00:16:47 thomas
|
||||
# added NOTEDB::mysql and changed note to work with that.
|
||||
# thus, from now on there is only one script to maintain and
|
||||
# it is possible to provide more bacjends as well as making
|
||||
# additional scripts upon them, i.e. cgi script...
|
||||
#
|
||||
# Revision 1.8 2000/03/13 22:48:43 thomas
|
||||
# small width bug fixed
|
||||
#
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user