Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#89 Matching patterns (keyword matching)

development
open
nobody
Program (79)
5
2003-09-15
2003-09-15
Anonymous
No

This patch implements a preferenceable "matching
pattern" feature including GUI for change of language
mode related "matching pattern set".

"Matching patterns" - in context of the patch - are
defined as groups of single characters (like '(', ')') or
literal strings (like '#ifdef', '#endif'), which match to
each other.

A matching pattern set is a collection of such matching
patterns.

"Opposite pattern highlighting" (aka "flashing") or "Goto
Matching" features are adapted by above patch to use
matching pattern sets i.s.o. a constant table.

Alternative start / end patterns as well as "middle"
patterns are allowed (Example "C preprocessor
conditional statement": Start = "#if" or "#ifndef"
or "#ifdef"; middle = "#elif" or "#else"; end = "#endif").

More info about the "matching pattern" feature can be
found in "FEATURE.txt" document (included in patch tar
ball).

Discussion

1 2 > >> (Page 1 of 2)
  • matching pattern feature tar ball

     
    Attachments
  • Uwe Lehnert
    Uwe Lehnert
    2003-09-15

    Logged In: YES
    user_id=794103

    Don't know, why this patch was submitted by "nobody".
    I was logged in (user "ulehnert") during submit of the patch.
    Nevertheless: Please send comments, bugs, requests etc.
    concerning this patch to "u dot lehnert at alcatel dot de".

     
  • Thorsten Haude
    Thorsten Haude
    2003-09-15

    Logged In: YES
    user_id=119143

    Very sweet idea. You haven't told us to which code version
    the patch should be applied, so I tried HEAD. The patch
    worked fine, but I get errosr on compile:

    cc -g -O2 -Wall -pedantic -I/usr/X11R6/include
    -DHAVE__XMVERSIONSTRING -DUSE_DIRENT -DUSE_LPR_PRINT_CMD -c
    patternMatchData.c -o patternMatchData.o
    patternMatchData.c: In function `helpCB':
    patternMatchData.c:4656: `HELP_MATCHING_PATTERNS' undeclared
    (first use in this function)
    patternMatchData.c:4656: (Each undeclared identifier is
    reported only once
    patternMatchData.c:4656: for each function it appears in.)
    patternMatchData.c: At top level:
    patternMatchData.c:3156: warning:
    `copyDialogMatchPatternElement' defined but not used
    patternMatchData.c:3178: warning: `copyDialogGroupElement'
    defined but not used
    make[1]: *** [patternMatchData.o] Error 1

     
  • Thorsten Haude
    Thorsten Haude
    2003-09-15

    Logged In: YES
    user_id=119143

    Yes, yes, RTFM, got you.

     
  • Thorsten Haude
    Thorsten Haude
    2003-09-15

    Logged In: YES
    user_id=119143

    This is great! I only played around for a few minutes, but
    it's useful already. Some questions:

    - Why not regexes? I want a start pattern of
    \<([^>])+\>
    and an end pattern of
    \</\1+\>
    to catch all XML tags.

    - I would expect the match to fire on any letter within the
    start/end pattern, not only the last letter. For example, if
    you have '<p>example</p>' the match should fire on the first
    four and the last five positions. (If you look for tags
    obvioulsly.)

    Great work on GUI and help! Most patches start as ugly hacks
    and only get these somewhere along the road (well, mine anyway).

     
  • Uwe Lehnert
    Uwe Lehnert
    2003-09-16

    Logged In: YES
    user_id=794103

    During design i considered to allow regular expressions for
    patterns. The problem is, that the pattern matching
    algorithm starts at current cursor position looking
    backward for a pattern in *original* window text buffer
    *char by char* (as the original matching algorithm does).
    This is done with *each* cursor movement. And I don't know,
    how i can do this "char by char backward search" with nedit
    build-in reg. ex. machine. After a pattern is found at
    current cursor pos., the pattern matching algo. already
    uses the reg. ex. machine to find the matching mate.
    Therefore a copy of the interesting text buffer is made.
    This copy takes quite some time. If this copy has to be
    done any time the cursor is moved, then it may slow down
    nedit too much.

    So: Does anybody know, how to realize "char by char
    backward reg. ex. search" without making a text buffer
    copy ?

    About "match to fire on any letter within a pattern": Never
    thought about this idea. The problem i see at a 1st glance:
    how to determine that the cursor is located inside a
    pattern without consuming to much processor time ? I'll
    think about it ...

     
  • Uwe Lehnert
    Uwe Lehnert
    2003-09-17

    Logged In: YES
    user_id=794103

    Some more info about this patch:

    The patch was made against "NEdit 5.4RC1" source tar ball
    (available at ftp://ftp.nedit.org/). I've tested the patch
    within
    following environment:

    Built on: Solaris, Sparc, GNU C
    With Motif: 1.2.6 [@(#)OSF/Motif Version 1.2.6]
    Running Motif: 1.2 [@(#)OSF/Motif Version 1.2.6]
    Server: Sun Microsystems, Inc. 6410

    Built on: Linux, 386, GNU C (Red Hat 9)
    With Motif: 2.1.30 [@(#)Motif Version 2.1.30]
    Running Motif: 2.1 [unknown]
    Server: The XFree86 Project, Inc 40300000

    README.txt (included in patch tar ball) includes some hints
    about
    how to apply the patch.

     
  • Eddy De Greef
    Eddy De Greef
    2003-11-05

    matching pattern V2.0 (by Uwe Lehnert)

     
    Attachments
  • Uwe Lehnert
    Uwe Lehnert
    2003-11-05

    Logged In: YES
    user_id=794103

    I've made version 2.0 of the "matching patterns
    (keyword matching)" patch (= mp031102-V2-0.tar.gz).

    README.txt (included in patch tar ball) again
    includes some hints about how to apply the patch.

    Changes since version 1.0:

    * Search for matching pattern is now also started,
    if cursor is located inside a string pattern
    (before: search was triggered, when cursor was
    located at end of string pattern).
    * Regular Expression String Patterns introduced as
    requested by Thorsten Haude (yooden).
    * New matching pattern set for language mode
    "XML" added (as example for reg. exp. string
    pattern).
    * Bug fix: flash matching pattern was not triggered
    sometimes, if some other patterns of the matching
    pattern set don't hold flash attribute
    (reference mismatch).

    The patch (mp031102-V2-0.tar.gz) was made against
    "NEdit 5.4RC2" source tarball (available at
    ftp://ftp.nedit.org/). I've tested the patch
    within already mentioned environments.

     
  • Logged In: NO

    Great patch!
    There is a small suggestion: For any default language
    there should at least be the parentheses defined, as you
    did for the Plain mode.

    There is another thing. The patch doesn't work well with
    Lestiff,
    see the develop list (maybe a Motif expert can help you).

    Best wishes

     
1 2 > >> (Page 1 of 2)