WinPTE.com

 

Incremental Search Functionality

An enhanced version of this macro was added in Release 3.00.445. It is left here as an example. You can compare this code to the one found in the main.pte to see how little had to be done to add the release enhancements.

Macro Features:

Instructions:

If the instructions are not clear then you may want to read the Quick Review on the parent page.

To give it a test flight:

To make it available every time you run WinPTE:

This is functionlity is part of the relase version as of 3.00.445. The instructions are only left here because they are useful for other macros. Do not make this version of the macro part of you standard installation unless you are running version 3.00.441 or earlier.

Macro Text

 Line 
       
    1 
    2 
    3 
    4 
    5 
    6 
    7 
    8 
    9 
   10 
   11 
   12 
   13 
   14 
   15 
   16 
   17 
   18 
   19 
   20 
   21 
   22 
   23 
   24 
   25 
   26 
   27 
   28 
   29 
   30 
   31 
   32 
   33 
   34 
   35 
   36 
   37 
   38 
   39 
   40 
   41 
   42 
   43 
   44 
   45 
   46 
   47 
   48 
   49 
   50 
   51 
   52 
   53 
   54 
   55 
   56 
   57 
   58 
   59 
   60 
   61 
   62 
   63 
   64 
   65 
   66 
   67 
   68 
   69 
   70 
   71 
   72 
   73 
   74 
   75 
   76 
   77 
   78 
   79 
   80 
   81 
   82 
   83 
   84 
   85 
   86 
   87 
   88 
   89 
   90 
   91 
   92 
   93 
   94 
   95 
   96 
   97 
   98 
   99 
  100 
  101 
  102 
  103 
  104 
  105 
  106 
  107 
  108 
  109 
* File: incrsearch.pte, lines 1 to 109
 
    * incremental search macro
    begindef c-i 
        [push cursor]
     
        [set envir 200]''    * search string
        [set envir 203][eval]'0b10001110'
        [set envir 205]''
        [set envir 206]'(down)'
     
        [push cursor]
        [do]
            [clear flag 200]    * direction key pressed, don't loop around
            [error #][envir 203]'Incremental Search '&[envir 206]&': '&[envir 200]&'|'
     
            [set envir 201][key name]
     
            [if escape]
                * drop modified position
                [drop cursor]
     
                * recall original
                [pop cursor]
                [exit loop]
            [endif]
     
            [clear next key]
            [set envir 202][string length][envir 201]
     
            [if eval]'$202>1'
                [if equal]'enter'[envir 201]
                    * drop modified position
                    [drop cursor]
                    [exit loop]
                [else if equal]'backspace'[envir 201]
                    * remove one key
                    [set envir 202][string length][envir 200]
                    [set envir 200][left string #][eval]'$202-1'[envir 200]
                [else if equal]'space'[envir 201]
                    [set envir 200][envir 200]&' '
                [else if equal]'down'[envir 201]
                    [if][down][endif]
                    [set flag 200]
                    [set envir 205]''
                    [set envir 206]'(down)'
                [else if equal]'right'[envir 201]
                    [if][right][endif]
                    [set flag 200]
                    [set envir 205]''
                    [set envir 206]'(down)'
                [else if equal]'up'[envir 201]
                    [if][up][endif]
                    [set flag 200]
                    [set envir 205]'-'
                    [set envir 206]'(up)'
                    [drop cursor]
                    [push cursor]
                [else if equal]'left'[envir 201]
                    [if][left]
                    [else if][up]
                        [end line]
                    [endif]
                    [set flag 200]
                    [set envir 205]'-'
                    [set envir 206]'(up)'
                [endif]
            [else]
                * add it to the search
                [set envir 200][envir 200]&[envir 201]
            [endif]
     
            [if flag 200]
                [drop cursor]
                [push cursor]
            [endif]
     
            [set envir 201]''
     
            [recall cursor]
     
            [set envir 203][eval]'0b10001110'
     
            [if not equal]''[envir 200]
                [if not][locate][envir 200][envir 205]
                    [if not flag 200]
                        [if equal]''[envir 205]
                            [top][begin line]
                        [else]
                            [bottom][end line]
                        [endif]
     
                        [if not][locate][envir 200][envir 205]
                            [set envir 203][eval]'0b10001101'
                            [recall cursor]
                        [else]
                            [center line]
                        [endif]
                    [else]
                        [set envir 203][eval]'0b10001101'
                    [endif]
                [else]
                    [center line]
                [endif]
            [endif]
        [loop]
     
        [error]              * clear the error
        * cursor left on stack so it can be recalled with sa-n
        *[drop cursor]
    enddef 
 
Site Map | Privacy Policy | Contact Us | ©2004 Winpte.com