diff --git a/Changelog b/Changelog index 2deb2e0..8cf5d3e 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,16 @@ +================================================================================ +1.2.4: +CHANGED: in the function find_editor() the alternatives vim and pico + has been removed because they would never had a match. +FIXED: applied patch by Bill Barnard + which fixes a bug in the sub format() which features bold + hidden or underlined text. Now its possible to use a ^ char + in hidden texts too. I applied the same for the other regexps. +ADDED: if the config variable FormatText is set to 'simple' then + only one * _ { or / will make the text tagged with them to + be displayed formatted, instead of two. +ADDED: added Term::ReadLine support (auto-completion and history). + ================================================================================ 1.2.3: ADDED: if FormatText is enabled one can now use a new special format diff --git a/README b/README index 641953f..5905729 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -note 1.2.3 by Thomas Linden, 08/03/2003 +note 1.2.4 by Thomas Linden, 22/03/2003 ======================================= Introduction @@ -73,6 +73,8 @@ o Note has scripting capabilities, you can create a new note by piping o for better performance, note can cache the database for listings or searching. o It can be installed without root-privileges. +o if Term::ReadLine (and Term::ReadLine::Gnu) is installed, history + and auto-completion are supported in interactive mode. o Last, a while ago a user stated: "... it simply does, what it says ..." @@ -92,7 +94,8 @@ You need the following things: mysql database backend. o The module DB_FILE if you want to use the DBM module. o Getopt::Long (part of perl std ditribution) - + o Term::ReadLine and optionally Term::ReadLine::Gnu if + you want to use the auto-completion and history functionality. Installation @@ -202,4 +205,4 @@ and I'll add you. Last changed ============ -08/03/2003 +22/03/2003 diff --git a/VERSION b/VERSION index 0495c4a..e8ea05d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.3 +1.2.4 diff --git a/VERSION~ b/VERSION~ new file mode 100644 index 0000000..e8ea05d --- /dev/null +++ b/VERSION~ @@ -0,0 +1 @@ +1.2.4 diff --git a/bin/note b/bin/note index 3573a65..07b8ab3 100755 --- a/bin/note +++ b/bin/note @@ -25,7 +25,7 @@ use strict; no strict 'refs'; -use Data::Dumper; +#use Data::Dumper; use Getopt::Long; # @@ -97,7 +97,7 @@ my ( $TYPE, $mode, $NoteKey, $TempDir, %Color, @LastTopic, $version, $CurTopic, $CurDepth, $WantTopic,$time_format, $sizeof, %TP, $TreeType, $ListType, $SetTitle, - @ArgTopics, $key, $typedef, @NumBlock, $has_nothing, + @ArgTopics, $key, $typedef, @NumBlock, $has_nothing, @completion_topics, @completion_notes, ); @@ -126,7 +126,7 @@ $TIME_COLOR = "blue"; $TOPIC_COLOR = "bold"; $TOPIC = 1; $TopicSep = '/'; -$version = "1.2.3"; +$version = "1.2.4"; if ($TOPIC) { $CurDepth = 1; # the current depth inside the topic "directory" structure... } @@ -673,13 +673,18 @@ sub list { else { $PATH = $TopicSep; } + + @completion_topics = (); + @completion_notes = (); # we are at top level, print a list of topics... foreach $top (sort(keys %TP)) { + push @completion_topics, $top; output("-", " => ". $top . "$TopicSep ($TP{$top} notes)", " Sub Topic "); } #print Dumper(@CurItem); for ($in=0;$in<$i;$in++) { + push @completion_notes, $CurItem[$in]->{'num'}; output( $CurItem[$in]->{'num'}, $CurItem[$in]->{'note'}, $CurItem[$in]->{'time'} ); @@ -955,6 +960,7 @@ sub clear { sub interactive { my($B, $BB, $menu, $char, $Channel); $Channel = $|; + local $| = 1; # create menu: $B = ""; $BB = ""; @@ -968,24 +974,42 @@ sub interactive { . $B . "E" . $BB . "-Edit " . $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! &determine_width; $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; &list; + my ($term, $prompt, $attribs); + eval { require Term::ReadLine; }; + if (!$@) { + $term = new Term::ReadLine(''); + $attribs = $term->Attribs; + $attribs->{completion_function} = \&complete; + } + for (;;) { $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; undef $SetTitle; if ($CurDepth > 2) { - print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; + print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . "> "; } else { - print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; + print C $menu . $TOPICC . $CurTopic . $_TOPICC . "> "; } + # endless until user press "Q" or "q"! - $char = ; - chomp $char; + if ($term) { + $char = $term->readline(""); + $term->addhistory($char) if $char =~ /\S/; + $char =~ s/\s*$//; # remove trailing whitespace (could come from auto-completion) + } + else { + $char = ; + chomp $char; + } + &determine_width; &clear; @@ -1173,7 +1197,7 @@ Read the note(1) manpage for more details. } sub find_editor { - return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vi" || "vim" || "pico"; + return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vi"; } #/ @@ -1194,12 +1218,21 @@ sub format { $IN =~ s/<(.*)>/<$1I>/; $_IN =~ s/<(.*)>/<$1I>/; - $note =~ s/\*\*([^\*^\*]*)\*\*/$BN$1$_BN/g; - $note =~ s/__([^_^_]*)__/$UN$1$_UN/g; - $note =~ s/{{([^}^}]*)}}/$IN$1$_IN/g; - $note =~ s#//([^/^/]*)//#$1#g; + if ($FormatText eq "simple") { + $note =~ s/\*([^\*]*)\*/$BN$1$_BN/g; + $note =~ s/_([^_]*)_/$UN$1$_UN/g; + $note =~ s/{([^}]*)}/$IN$1$_IN/g; + $note =~ s#(?$1#g; + } + else { + $note =~ s/\*\*([^\*]{2,})\*\*/$BN$1$_BN/g; + $note =~ s/__([^_]{2,})__/$UN$1$_UN/g; + $note =~ s/{{([^}]{2,})}}/$IN$1$_IN/g; + $note =~ s#//([^/]{2,})//#$1#g; + } + + $note =~ s/(<\/.*>)/$1$NOTEC/g; } - $note =~ s/(<\/.*>)/$1$NOTEC/g; $note; } @@ -1518,8 +1551,7 @@ sub print_tree { } -sub getconfig - { +sub getconfig { my($configfile) = @_; my ($home, $value, $option); # checks are already done, so trust myself and just open it! @@ -1583,9 +1615,34 @@ sub getconfig $libpath =~ s/\/*$//; close CONFIG; - } +} +sub complete { + my ($text, $line, $start) = @_; + + if ($line =~ /^\s*$/) { + # notes or topics allowed + return @completion_topics, @completion_notes; + } + if ($line =~ /^cd/) { + # only topics allowed + return @completion_topics, ".."; + } + if ($line =~ /^l/i) { + # only topics allowed + return @completion_topics; + } + if ($line =~ /^[ed]/) { + # only notes allowed + return @completion_notes; + } + if ($line =~ /^[snt\?q]/i) { + # nothing allowed + return (); + } +} + __END__ diff --git a/config/noterc b/config/noterc index a2f3a19..f86499e 100644 --- a/config/noterc +++ b/config/noterc @@ -1,4 +1,4 @@ -# 1.2.2 -*- sh -*- +# 1.2.4 -*- sh -*- # This is a sample config for the note script # There are useful defaults set in note itself. # @@ -148,7 +148,7 @@ TopicColor BLACK # Additional to colors, you can also do a little bit of formatting your # notes (bold, underlined, italic), see README! # You need to set this Option to 1, if you decide to make use of this -# capabily +# capabily. You can also set it to 'simple' to achieve a simplified syntax. FormatText 1 diff --git a/note.pod b/note.pod index 0d9e8d3..be59b58 100644 --- a/note.pod +++ b/note.pod @@ -439,21 +439,29 @@ black, red, green, yellow, blue, magenta, cyan and white. Beside colorizing text, you can also create bold or underlined text! If you decide to use this (additional) feature, you need to set the -Config-Option "FormatNotes" to 1 which turns it on. +Config-Option "FormatText" to 1 which turns it on. Usage is very straightforward, if a word (a word is defined as some text with at least one space surrounded) is between a magic mark- character. Here are the available things, you can do: - bold: **word** - underlined:__word__ - inverse:{{word}} - hidden: //word// + bold: **word** + underlined: __word__ + inverse: {{word}} + hidden: //word// The text will be formatted using the actually note-color. The hidden formatting will use blue forground and blue background to hide a string from the terminal, which is usefull for passwords. +If you set "FormatText" to I then the formatting can be +done this way instead: + + bold: *word* + underlined: _word_ + inverse: {word} + hidden: /word/ + =head1 ENCRYPTION You can turn on encryption from the config file. @@ -505,6 +513,6 @@ Thomas Linden =head1 VERSION -1.2.3 (08/03/2003) +1.2.4 (19/03/2003) =cut