Changeset 2565


Ignore:
Timestamp:
Dec 28, 2012, 6:56:51 PM (12 years ago)
Author:
Andreas Schnellbacher
Message:
  • Fixed: After all-searching for nothing with 'all /', the keyset wasn't reset.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/netlabs/macros/all.e

    r2541 r2565  
    5858compile endif
    5959
     60; ---------------------------------------------------------------------------
    6061; ALL macro
    6162defc All
     
    6465   universal default_search_options
    6566   universal activeaccel
     67
     68   allsrch = strip( arg(1), 'L')
     69   if allsrch = '' or allsrch = '/' then
     70      sayerror 'All: Error: search string is missing.'
     71      return
     72   endif
     73
    6674   call psave_pos(save_pos)
    67    if .filename = '.ALL' & arg(1) then
    68       .filename = '.prev_ALL'
    69    endif
    70 
    7175   getfileid allorig
    72    call SetAVar( 'prevkeyset.'allorig, activeaccel)
    73    -- Extend keyset
    74    'SetKeyset all' activeaccel'value' 'all'
    75 
     76
     77   if GetAVar( 'prevkeyset.'allorig) = '' then
     78      -- Save previous keyset
     79      call SetAVar( 'prevkeyset.'allorig, activeaccel)
     80      -- Extend keyset
     81      'SetKeyset all' activeaccel'value' 'all'
     82   endif
     83
     84   -- Rename previous .ALL file, if found
     85   getfileid prevallfile, '.ALL'
     86   if prevallfile <> '' then
     87      prevallfile.filename = '.prev_ALL'
     88   endif
     89
     90   -- Create new .ALL file
    7691   'e /q /n .ALL'    -- Don't use XCOM so can handle either windowing style
    7792   .filename = '.ALL'
     
    7994   -- Extend keyset
    8095   'PostMe SetKeyset all' activeaccel'value' 'all'  -- PostMe required
    81 
    82    allsrch = strip( arg(1), 'L')
    83    if allsrch = '' then
    84       .modify = 0
    85       'q'
    86       if allorig <> allfile then
    87          activatefile allorig
    88          -- Restore keyset
    89          PrevKeyset = GetAVar( 'prevkeyset.'allorig)
    90          'SetKeyset' PrevKeyset
    91       endif
    92       sayerror 1
    93       return
    94    endif
    9596   for i = 1 to .last
    9697      deleteline 1
     
    99100   activatefile allorig
    100101
    101     -- Copied from DEFC L - we only will use E or C (case) and A or M (mark)
    102     DSO = ''   -- DSO = subset of default_search_options
    103     do i = 1 to length(default_search_options)
    104        ch = substr( default_search_options, i, 1)
    105        if pos( ch, 'EeCcAaMm') > 0 then
    106           DSO = DSO''ch
    107        endif
    108     end
    109     -- Insert default_search_options just before supplied options (if any)
    110     -- so the supplied options will take precedence.
     102   -- Copied from DEFC L - we only will use E or C (case) and A or M (mark)
     103   DSO = ''   -- DSO = subset of default_search_options
     104   do i = 1 to length( default_search_options)
     105      ch = substr( default_search_options, i, 1)
     106      if pos( ch, 'EeCcAaMm') > 0 then
     107         DSO = DSO''ch
     108      endif
     109   end
     110   -- Insert default_search_options just before supplied options (if any)
     111   -- so the supplied options will take precedence.
    111112;   if DSO then
    112        ch = substr( allsrch, 1, 1)
    113        p  = pos( ch, allsrch, 2)
    114        user_options = ''
    115        if p > 0 then
    116           user_options = substr( allsrch, p + 1)
    117           allsrch      = substr( allsrch, 1, p - 1)
    118        endif
    119        allsrch = allsrch''ch''DSO''user_options
     113      ch = substr( allsrch, 1, 1)
     114      p  = pos( ch, allsrch, 2)
     115      user_options = ''
     116      if p > 0 then
     117         user_options = substr( allsrch, p + 1)
     118         allsrch      = substr( allsrch, 1, p - 1)
     119      endif
     120      allsrch = allsrch''ch''DSO''user_options
    120121;   endif
    121122   last_line = .last
     
    136137      endif
    137138      getline line
    138       line = rightstr( .line, 5) line  -- prepend line no
     139      -- Prepend line no
     140      line = rightstr( .line, 5) line
    139141      insertline line, allfile.last + 1, allfile
    140142      if .line = last_line then
     
    149151      .modify = 0
    150152      'q'
    151       activatefile allorig
    152       -- Restore keyset
    153       PrevKeyset = GetAVar( 'prevkeyset.'allorig)
    154       'SetKeyset' PrevKeyset
    155153      sayerror -273  -- sayerror("String not found")
     154      'AllEndSwitchFiles'
    156155      return
    157156   endif
     
    162161   top
    163162   .col = 7
    164    'postme l' allsrch'A'  -- Position cursor under first hit.
     163   'PostMe l' allsrch'A'  -- Position cursor under first hit.
    165164                          -- Use l, not xcom l to highlight hit.
    166165   AllKey = strip( MenuAccelString( 'AllSwitchFiles'), 'l', \9)
    167166   'SayHint Press 'AllKey' to switch between this and the original file'
    168167
     168; ---------------------------------------------------------------------------
    169169; Shows the .ALL file's current line in the original file
    170170defc AllSwitchFiles
     
    176176      if allfile = '' then
    177177         sayerror NO_ALL_FILE__MSG
     178         'AllEndSwitchFiles'
    178179      else
    179180         activatefile allfile
     
    189190         else                                       -- Scroll!
    190191            '+1'
    191             oldline = .line
     192            oldlinenum = .line
    192193            .cursory = (.windowheight + 1)%2        -- Center vertically
    193             oldline
     194            oldlinenum
    194195         endif
    195196         .col = 6  -- Skip line number for search
    196          'l' allsrch'A'
     197         'l' allsrch'A'  -- Match on first .ALL line is not highlighted, even not with PostMe
    197198      endif
    198199      return
    199200   endif  -- .filename <> '.ALL'
    200201   getline line
    201    parse value line with line .
    202    if not isnum(line) then
     202   parse value line with linenum .
     203   if not isnum( linenum) then
    203204      sayerror BAD_ALL_LINE__MSG
     205      'AllEndSwitchFiles'
    204206      return
    205207   endif
     
    207209   'SetKeyset all' activeaccel'value' 'all'  -- ensure that orig file has 'all' keyset
    208210   .cursory = .windowheight%2                       -- Center vertically
    209    line
     211   linenum
    210212   .col = 1
    211    'l' allsrch'A'  -- Use l, not xcom l to highlight hit.
    212 
     213   'PostMe l' allsrch'A'  -- Use l, not xcom l to highlight hit, PostMe required
     214
     215; ---------------------------------------------------------------------------
    213216defc AllEndSwitchFiles
    214217   universal allorig
    215    universal allsrch
    216218   -- Restore keyset
    217219   activatefile allorig
Note: See TracChangeset for help on using the changeset viewer.