CVSROOT: /home/x-cvs
Module name: xc
Changes by: [EMAIL PROTECTED] 02/09/07 19:29:50
Log message:
o Added a regex library for fast matching tokens. This library is very
limited in wich patterns it can handle, has only one level "backtracking",
so it will not always properly match complex patterns envolving
.*, .+, and .?.
.{...} is not supported. But for "simple" patterns, or patterns that only
have one "atomic" subpattern after a .<repetition-operator> it should
always return the expected result. This initial version handles far more
than what is required by the prototype of the new generic xedit
syntax-highlight xedit, and for the some patterns/inputs, it can be even
more than 200 times faster than normal regex. The library generates the
same results as the previous version of the syntax-highlight prototype
using system/standard regex, but, almost without modifications, the
execution time is now 4 times faster. See more details in the README file.
I tried to make the code as reusable as possible, so that it can be
useful to other people. Probably I will not do it in a short time, but
after this initial implementation I started thinking about several ways
to make a version that handles all kinds of patterns and can still be
very fast.
o Fixed a long standing bug in xedit, when typing text and saving the
contents of the scrath buffer to a file, it would not remove the changed
callback so if the new file was later modified, it would think that the
scratch buffer was also modified.
o Fixed another old bug in Xaw that would not correctly draw text before
tabs if the text window was scrolled horizontally.
o Changed code in TextSrc.c to not allow text entities with zero length.
o Added a line-edit mode to xedit. The commands are based on ed. Please
see the changes to the xedit manual page for a description of the
commands. The major reason was to have a way to test the regex library
and also adds a good usage to the <Escape> key, instead of adding an
<Escape> to the text, it enters the line-edit mode. Since most the ed
commands are close to vi, vi users will find it very simple to use.
The major difference is that it is not required to type : before a
command.
Some examples of use:
- load a file
- type <Escape>
- type /<some-text>
- type <Return>
Every time <Return> is typed, it will move to the next occurrence
of <some-text> and highlight it.
- type ,s/<re>/<substition>
- type <Return>
It will replace all matches to <re> with <substition> and
return to edit mode.
- type ,s/<re>/<substition>/c
- type <Return>
It will highlight the next match to <re> and wait for input, if
you type y or Y it will replace the text, if you type n or N, it
will ignore it and search the next pattern.
Type ",s/<re>/<substition>/g" to replace all matches in a line.
Type ",s/<re>/<substition>/<nth>" to only replace the nth
match in a line.
Options can go after the "s" so you don't need to type the ending
"/", for example ",sgc/<re>/<text>" is the same as
",s/<re>/<text>/gc"
It also handles backreferences, but note that these are not in
any way supported in the current version of the regex library
if used with repetition operators. Anyway, here is a sample of
a possible usage:
- type <Escape> (go to line-edit mode)
- type ,s/\<(foo|fee)(\s+)(bar|baz)\>/\3\2\1
- type <Return>
"foo bar" will be replaced by "bar foo"
"fee bar" will be replaced by "bar fee"
"foo baz" will be replaced by "baz foo"
"fee baz" will be replaced by "baz fee"
Add the "i" option and it will be case insensitive.
Remove the "\<" and the "\>" and it will match words
ending with "foo" or "fee" and words starting with "bar" or "baz".
This describes most of the currently supported options.
Modified files:
xc/lib/Xaw/:
AsciiSink.c TextSrc.c
xc/programs/xedit/:
Imakefile Xedit.ad commands.c hook.c lisp.c xedit.c
xedit.h xedit.man
xc/programs/xedit/lisp/:
Imakefile helper.c internal.h lisp.c regex.c regex.h
write.c
xc/programs/xedit/lisp/modules/:
syntax.lsp
xc/programs/xedit/lisp/modules/progmodes/:
c.lsp
Added files:
xc/programs/xedit/lisp/re/:
Imakefile README re.c re.h rec.c reo.c rep.h tests.c
tests.txt
Revision Changes Path
1.28 +5 -6 xc/lib/Xaw/AsciiSink.c
1.33 +4 -0 xc/lib/Xaw/TextSrc.c
1.22 +4 -3 xc/programs/xedit/Imakefile
1.22 +2 -1 xc/programs/xedit/Xedit.ad
1.28 +13 -4 xc/programs/xedit/commands.c
1.6 +874 -4 xc/programs/xedit/hook.c
1.10 +6 -9 xc/programs/xedit/lisp.c
1.16 +3 -1 xc/programs/xedit/xedit.c
1.15 +3 -0 xc/programs/xedit/xedit.h
1.17 +115 -0 xc/programs/xedit/xedit.man
1.19 +5 -5 xc/programs/xedit/lisp/Imakefile
1.34 +3 -5 xc/programs/xedit/lisp/helper.c
1.30 +3 -5 xc/programs/xedit/lisp/internal.h
1.59 +5 -5 xc/programs/xedit/lisp/lisp.c
1.4 +56 -124 xc/programs/xedit/lisp/regex.c
1.2 +4 -4 xc/programs/xedit/lisp/regex.h
1.10 +5 -17 xc/programs/xedit/lisp/write.c
1.5 +25 -21 xc/programs/xedit/lisp/modules/syntax.lsp
1.5 +34 -28 xc/programs/xedit/lisp/modules/progmodes/c.lsp
_______________________________________________
Cvs-commit mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/cvs-commit