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:
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
@@ -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

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;
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 = "<white_black>";
$BB = "</white_black>";
@@ -968,12 +974,21 @@ 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;
@@ -983,9 +998,18 @@ sub interactive {
else {
print C $menu . $TOPICC . $CurTopic . $_TOPICC . "> ";
}
# endless until user press "Q" or "q"!
if ($term) {
$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;
&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#//([^/^/]*)//#<hide>$1</hide>#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#(?<!<)/([^/]*)/#<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;
}
@@ -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!
@@ -1586,6 +1618,31 @@ sub getconfig
}
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__

View File

@@ -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

View File

@@ -439,7 +439,7 @@ 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:
@@ -454,6 +454,14 @@ 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<simple> 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 <tom@daemon.de>
=head1 VERSION
1.2.3 (08/03/2003)
1.2.4 (19/03/2003)
=cut