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 <bill@barnard-engineering.com>
                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).
This commit is contained in:
TLINDEN
2012-02-10 20:29:36 +01:00
parent a43f27d328
commit adb457de48
7 changed files with 110 additions and 28 deletions

View File

@@ -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 <bill@barnard-engineering.com>
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: 1.2.3:
ADDED: if FormatText is enabled one can now use a new special format ADDED: if FormatText is enabled one can now use a new special format

9
README
View File

@@ -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 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 o for better performance, note can cache the database for listings
or searching. or searching.
o It can be installed without root-privileges. 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 o Last, a while ago a user stated: "... it simply does, what it
says ..." says ..."
@@ -92,7 +94,8 @@ You need the following things:
mysql database backend. mysql database backend.
o The module DB_FILE if you want to use the DBM module. o The module DB_FILE if you want to use the DBM module.
o Getopt::Long (part of perl std ditribution) 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 Installation
@@ -202,4 +205,4 @@ and I'll add you.
Last changed Last changed
============ ============
08/03/2003 22/03/2003

View File

@@ -1 +1 @@
1.2.3 1.2.4

1
VERSION~ Normal file
View File

@@ -0,0 +1 @@
1.2.4

View File

@@ -25,7 +25,7 @@
use strict; use strict;
no strict 'refs'; no strict 'refs';
use Data::Dumper; #use Data::Dumper;
use Getopt::Long; use Getopt::Long;
# #
@@ -97,7 +97,7 @@ my (
$TYPE, $mode, $NoteKey, $TempDir, %Color, @LastTopic, $TYPE, $mode, $NoteKey, $TempDir, %Color, @LastTopic,
$version, $CurTopic, $CurDepth, $WantTopic,$time_format, $version, $CurTopic, $CurDepth, $WantTopic,$time_format,
$sizeof, %TP, $TreeType, $ListType, $SetTitle, $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_COLOR = "bold";
$TOPIC = 1; $TOPIC = 1;
$TopicSep = '/'; $TopicSep = '/';
$version = "1.2.3"; $version = "1.2.4";
if ($TOPIC) { if ($TOPIC) {
$CurDepth = 1; # the current depth inside the topic "directory" structure... $CurDepth = 1; # the current depth inside the topic "directory" structure...
} }
@@ -673,13 +673,18 @@ sub list {
else { else {
$PATH = $TopicSep; $PATH = $TopicSep;
} }
@completion_topics = ();
@completion_notes = ();
# we are at top level, print a list of topics... # we are at top level, print a list of topics...
foreach $top (sort(keys %TP)) { foreach $top (sort(keys %TP)) {
push @completion_topics, $top;
output("-", " => ". $top . "$TopicSep ($TP{$top} notes)", output("-", " => ". $top . "$TopicSep ($TP{$top} notes)",
" Sub Topic "); " Sub Topic ");
} }
#print Dumper(@CurItem); #print Dumper(@CurItem);
for ($in=0;$in<$i;$in++) { for ($in=0;$in<$i;$in++) {
push @completion_notes, $CurItem[$in]->{'num'};
output( $CurItem[$in]->{'num'}, output( $CurItem[$in]->{'num'},
$CurItem[$in]->{'note'}, $CurItem[$in]->{'note'},
$CurItem[$in]->{'time'} ); $CurItem[$in]->{'time'} );
@@ -955,6 +960,7 @@ sub clear {
sub interactive { sub interactive {
my($B, $BB, $menu, $char, $Channel); my($B, $BB, $menu, $char, $Channel);
$Channel = $|; $Channel = $|;
local $| = 1;
# create menu: # create menu:
$B = "<white_black>"; $B = "<white_black>";
$BB = "</white_black>"; $BB = "</white_black>";
@@ -968,24 +974,42 @@ sub interactive {
. $B . "E" . $BB . "-Edit " . $B . "E" . $BB . "-Edit "
. $B . "?" . $BB . "-Help " . $B . "?" . $BB . "-Help "
. $B . "Q" . $BB . "-Quit] "; # $CurTopic will be empty if $TOPIC is off! . $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! # Initially do a list command!
&determine_width; &determine_width;
$ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : "";
&list; &list;
my ($term, $prompt, $attribs);
eval { require Term::ReadLine; };
if (!$@) {
$term = new Term::ReadLine('');
$attribs = $term->Attribs;
$attribs->{completion_function} = \&complete;
}
for (;;) { for (;;) {
$ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : "";
undef $SetTitle; undef $SetTitle;
if ($CurDepth > 2) { if ($CurDepth > 2) {
print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . "> ";
} }
else { else {
print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; print C $menu . $TOPICC . $CurTopic . $_TOPICC . "> ";
} }
# endless until user press "Q" or "q"! # endless until user press "Q" or "q"!
$char = <STDIN>; if ($term) {
chomp $char; $char = $term->readline("");
$term->addhistory($char) if $char =~ /\S/;
$char =~ s/\s*$//; # remove trailing whitespace (could come from auto-completion)
}
else {
$char = <STDIN>;
chomp $char;
}
&determine_width; &determine_width;
&clear; &clear;
@@ -1173,7 +1197,7 @@ Read the note(1) manpage for more details.
} }
sub find_editor { 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>/;
$_IN =~ s/<(.*)>/<$1I>/; $_IN =~ s/<(.*)>/<$1I>/;
$note =~ s/\*\*([^\*^\*]*)\*\*/$BN$1$_BN/g; if ($FormatText eq "simple") {
$note =~ s/__([^_^_]*)__/$UN$1$_UN/g; $note =~ s/\*([^\*]*)\*/$BN$1$_BN/g;
$note =~ s/{{([^}^}]*)}}/$IN$1$_IN/g; $note =~ s/_([^_]*)_/$UN$1$_UN/g;
$note =~ s#//([^/^/]*)//#<hide>$1</hide>#g; $note =~ s/{([^}]*)}/$IN$1$_IN/g;
$note =~ s#(?<!<)/([^/]*)/#<hide>$1</hide>#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,})//#<hide>$1</hide>#g;
}
$note =~ s/(<\/.*>)/$1$NOTEC/g;
} }
$note =~ s/(<\/.*>)/$1$NOTEC/g;
$note; $note;
} }
@@ -1518,8 +1551,7 @@ sub print_tree {
} }
sub getconfig sub getconfig {
{
my($configfile) = @_; my($configfile) = @_;
my ($home, $value, $option); my ($home, $value, $option);
# checks are already done, so trust myself and just open it! # checks are already done, so trust myself and just open it!
@@ -1583,9 +1615,34 @@ sub getconfig
$libpath =~ s/\/*$//; $libpath =~ s/\/*$//;
close CONFIG; 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__ __END__

View File

@@ -1,4 +1,4 @@
# 1.2.2 -*- sh -*- # 1.2.4 -*- sh -*-
# This is a sample config for the note script # This is a sample config for the note script
# There are useful defaults set in note itself. # 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 # Additional to colors, you can also do a little bit of formatting your
# notes (bold, underlined, italic), see README! # notes (bold, underlined, italic), see README!
# You need to set this Option to 1, if you decide to make use of this # 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 FormatText 1

View File

@@ -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 Beside colorizing text, you can also create bold or underlined text! If
you decide to use this (additional) feature, you need to set the 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 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- text with at least one space surrounded) is between a magic mark-
character. Here are the available things, you can do: character. Here are the available things, you can do:
bold: **word** bold: **word**
underlined:__word__ underlined: __word__
inverse:{{word}} inverse: {{word}}
hidden: //word// hidden: //word//
The text will be formatted using the actually note-color. The text will be formatted using the actually note-color.
The hidden formatting will use blue forground and blue background The hidden formatting will use blue forground and blue background
to hide a string from the terminal, which is usefull for passwords. to hide a string from the terminal, which is usefull for passwords.
If you set "FormatText" to I<simple> then the formatting can be
done this way instead:
bold: *word*
underlined: _word_
inverse: {word}
hidden: /word/
=head1 ENCRYPTION =head1 ENCRYPTION
You can turn on encryption from the config file. You can turn on encryption from the config file.
@@ -505,6 +513,6 @@ Thomas Linden <tom@daemon.de>
=head1 VERSION =head1 VERSION
1.2.3 (08/03/2003) 1.2.4 (19/03/2003)
=cut =cut