about summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* applied Jukkas remark (dunno if this is correct though)arg@mmvi2006-09-221-2/+2
|
* applied jukkas patcharg@mmvi2006-09-221-8/+4
|
* man page fixarg@mmvi2006-09-221-1/+1
|
* ismax toggling on mouse based actionarg@mmvi2006-09-221-0/+2
|
* hotfixarg@mmvi2006-09-221-5/+5
|
* small change to achieve Jukka's last proposalarg@mmvi2006-09-222-14/+34
|
* fixed issue pointed out by Jukkaarg@mmvi2006-09-224-10/+5
|
* patched resizemouse according to sanders remarkarg@mmvi2006-09-221-2/+2
|
* small man page fixarg@mmvi2006-09-221-0/+1
|
* sander check thisarg@mmvi2006-09-221-19/+37
|
* slight change to config.arg.h (I use ff floating)arg@mmvi2006-09-221-1/+1
|
* updated man pagearg@mmvi2006-09-221-5/+1
|
* implemented the maximization as I described on the mailinglist, this feels ↵arg@mmvi2006-09-227-50/+25
| | | | better to me.
* reviewed client.carg@mmvi2006-09-201-0/+1
|
* reviewed util.carg@mmvi2006-09-201-1/+2
|
* fixed a nuance in dwm.1arg@mmvi2006-09-201-1/+1
|
* improved intro comment in dwm.h, updated config.mkarg@mmvi2006-09-202-4/+4
|
* some simplifications to intro in dwm.harg@mmvi2006-09-191-13/+13
|
* Added tag 1.6 for changeset ad3fa2d185426c51fd5deceae809770363f8d33carg@mmvi2006-09-161-0/+1
|
* added visibility check to enternotify as well 1.6arg@mmvi2006-09-151-1/+1
|
* offscreen client appearance fixesarg@mmvi2006-09-151-0/+10
|
* focus() enforces visibility of a client if not NULLarg@mmvi2006-09-151-1/+1
|
* removed useless inclusionAnselm R. Garbe2006-09-141-1/+0
|
* fixed executing of dmenu output to handle args correctlyAnselm R. Garbe2006-09-121-1/+1
|
* removed a bunch of lines through making function signatures more consistent ↵Anselm R. Garbe2006-09-127-158/+83
| | | | with my style ( { does not belong to a new line, if function args are single-lined)
* some more simplifications of intro comment in dwm.h, this should suffice for ↵Anselm R. Garbe2006-09-121-20/+14
| | | | comments in dwm
* made introduction comment in dwm.h shorterAnselm R. Garbe2006-09-121-20/+15
|
* applied Christof Musik's multihead patch for a pathologic cornercaseAnselm R. Garbe2006-09-121-1/+2
|
* added a general comment to dwm.h how dwm is basically organizedAnselm R. Garbe2006-09-121-0/+40
|
* some other simplificationsAnselm R. Garbe2006-09-111-11/+11
|
* fixed some other comments, now also the code side seems to be at a level to ↵Anselm R. Garbe2006-09-111-2/+2
| | | | be reviewed by experienced programmers
* small change to comments, renamed two set* functions in client.c into update*Anselm R. Garbe2006-09-113-17/+17
|
* small fixAnselm R. Garbe2006-09-112-3/+3
|
* added some commentsAnselm R. Garbe2006-09-112-75/+72
|
* Added tag 1.5 for changeset 728c9089b079721b43c3347124639a29baa22a97Anselm R. Garbe2006-09-081-0/+1
|
* applied sanders patch of not manipulating sel 1.5Anselm R. Garbe2006-09-082-6/+8
|
* really small changes to dwm.1Anselm R. Garbe2006-09-081-4/+3
|
* hotfixAnselm R. Garbe2006-09-071-1/+1
|
* simplified unmanageAnselm R. Garbe2006-09-071-8/+2
|
* using a global stack for focus recovery on arrange() - seems to work greatAnselm R. Garbe2006-09-074-8/+26
|
* made markups in dwm.1 more consistentAnselm R. Garbe2006-09-071-95/+38
|
* small addition to dwm.1Anselm R. Garbe2006-09-071-4/+4
|
* this patch keeps track of global z-layer order of clients which are floating ↵Anselm R. Garbe2006-09-061-12/+7
| | | | or if floating mode is enabled
* no this is betterAnselm R. Garbe2006-09-062-11/+11
|
* does this preserve z order for anthony?Anselm R. Garbe2006-09-062-8/+10
|
* maybe this might workAnselm R. Garbe2006-09-063-4/+9
|
* Added tag 1.4 for changeset 3cff9403766bf83a9fc2a0aef230115d68de2a8eAnselm R. Garbe2006-09-061-0/+1
|
* prepared dwm-1.4 update 1.4Anselm R. Garbe2006-09-062-2/+1
|
* drawstatus even if no client existsAnselm R. Garbe2006-09-061-1/+3
|
* sanders solution is convincing and elegantAnselm R. Garbe2006-09-062-49/+9
|
e25474154 ^

d68181246 ^
1102b8ac6 ^
e25474154 ^
d68181246 ^
e25474154 ^
d68181246 ^
e25474154 ^
d68181246 ^
e25474154 ^
c06f73b48 ^
eddf9abd1 ^
e25474154 ^


d68181246 ^
e25474154 ^
b731e6ef1 ^
e25474154 ^
d68181246 ^
e25474154 ^

d68181246 ^
e25474154 ^
b731e6ef1 ^
e25474154 ^
d68181246 ^

2df9b442c ^
e25474154 ^


d68181246 ^
e25474154 ^

eddf9abd1 ^
1102b8ac6 ^
e25474154 ^

b731e6ef1 ^
e25474154 ^

92b8fac94 ^
e25474154 ^
d68181246 ^
e25474154 ^

d68181246 ^
e25474154 ^
6c5693e63 ^
d68181246 ^
7e747d11c ^
e25474154 ^
dc669155e ^
d68181246 ^
58186f6c1 ^
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

 
                            
                                         









                                                                 
      

                    
     










                     
     







                                                                           
    
                                 
                
                
                                                        
                                                       


                                                                  
                                                                             
 

                                                              




                                                                
                                                


                                                                      
                                                




                                                                      
                                        
                         
 

                                    





                                                             

                                     
                     
                
                                                              
                                           
                                                                        
                        
                                

                                              
       

                                                 
               
                           
                                                           
                

                                                           

             

                                                                   


                                                  
                                                                  
                                           
                                 

                                                  
               
                         
 
                                                      
                           
                      
                                             
       
                 
                           
                


                      
                                                 
                          
                   
                                
                         

                                     
                                                 
                          
                   
                                                                               

                                     
                                                                      


                       
                                                                              

                    
                  
                           

                         
                                                

                        
                
 
                                                 

                                 
                                                                 
             
                     
                                              
                        
          
                  
            
                                                              
#
#
#           The Nim Compiler
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# Base Object of a lexer with efficient buffer handling. In fact
# I believe that this is the most efficient method of buffer
# handling that exists! Only at line endings checks are necessary
# if the buffer needs refilling.

import
  llstream, strutils

const
  Lrz* = ' '
  Apo* = '\''
  Tabulator* = '\x09'
  ESC* = '\x1B'
  CR* = '\x0D'
  FF* = '\x0C'
  LF* = '\x0A'
  BEL* = '\x07'
  BACKSPACE* = '\x08'
  VT* = '\x0B'

const
  EndOfFile* = '\0'           # end of file marker
                              # A little picture makes everything clear :-)
                              #  buf:
                              #  "Example Text\n ha!"   bufLen = 17
                              #   ^pos = 0     ^ sentinel = 12
                              #
  NewLines* = {CR, LF}

type
  TBaseLexer* = object of RootObj
    bufpos*: int
    buf*: string
    stream*: PLLStream        # we read from this stream
    lineNumber*: int          # the current line number
                              # private data:
    sentinel*: int
    lineStart*: int           # index of last line start in buffer
    offsetBase*: int          # use ``offsetBase + bufpos`` to get the offset


proc openBaseLexer*(L: var TBaseLexer, inputstream: PLLStream,
                    bufLen: int = 8192)
  # 8K is a reasonable buffer size
proc closeBaseLexer*(L: var TBaseLexer)
proc getCurrentLine*(L: TBaseLexer, marker: bool = true): string
proc getColNumber*(L: TBaseLexer, pos: int): int
proc handleCR*(L: var TBaseLexer, pos: int): int
  # Call this if you scanned over CR in the buffer; it returns the
  # position to continue the scanning from. `pos` must be the position
  # of the CR.
proc handleLF*(L: var TBaseLexer, pos: int): int
  # Call this if you scanned over LF in the buffer; it returns the the
  # position to continue the scanning from. `pos` must be the position
  # of the LF.
# implementation

proc closeBaseLexer(L: var TBaseLexer) =
  llStreamClose(L.stream)

proc fillBuffer(L: var TBaseLexer) =
  var
    charsRead, toCopy, s: int # all are in characters,
                              # not bytes (in case this
                              # is not the same)
    oldBufLen: int
  # we know here that pos == L.sentinel, but not if this proc
  # is called the first time by initBaseLexer()
  assert(L.sentinel < L.buf.len)
  toCopy = L.buf.len - L.sentinel - 1
  assert(toCopy >= 0)
  if toCopy > 0:
    moveMem(addr L.buf[0], addr L.buf[L.sentinel + 1], toCopy)
    # "moveMem" handles overlapping regions
  charsRead = llStreamRead(L.stream, addr L.buf[toCopy], L.sentinel + 1)
  s = toCopy + charsRead
  if charsRead < L.sentinel + 1:
    L.buf[s] = EndOfFile      # set end marker
    L.sentinel = s
  else:
    # compute sentinel:
    dec(s)                    # BUGFIX (valgrind)
    while true:
      assert(s < L.buf.len)
      while (s >= 0) and not (L.buf[s] in NewLines): dec(s)
      if s >= 0:
        # we found an appropriate character for a sentinel:
        L.sentinel = s
        break
      else:
        # rather than to give up here because the line is too long,
        # double the buffer's size and try again:
        oldBufLen = L.buf.len
        L.buf.setLen(L.buf.len * 2)
        assert(L.buf.len - oldBufLen == oldBufLen)
        charsRead = llStreamRead(L.stream, addr(L.buf[oldBufLen]),
                                 oldBufLen)
        if charsRead < oldBufLen:
          L.buf[oldBufLen + charsRead] = EndOfFile
          L.sentinel = oldBufLen + charsRead
          break
        s = L.buf.len - 1

proc fillBaseLexer(L: var TBaseLexer, pos: int): int =
  assert(pos <= L.sentinel)
  if pos < L.sentinel:
    result = pos + 1          # nothing to do
  else:
    fillBuffer(L)
    L.offsetBase += pos + 1
    L.bufpos = 0
    result = 0
  L.lineStart = result

proc handleCR(L: var TBaseLexer, pos: int): int =
  assert(L.buf[pos] == CR)
  inc(L.lineNumber)
  result = fillBaseLexer(L, pos)
  if L.buf[result] == LF:
    result = fillBaseLexer(L, result)

proc handleLF(L: var TBaseLexer, pos: int): int =
  assert(L.buf[pos] == LF)
  inc(L.lineNumber)
  result = fillBaseLexer(L, pos) #L.lastNL := result-1; // BUGFIX: was: result;

proc skipUTF8BOM(L: var TBaseLexer) =
  if L.buf[0] == '\xEF' and L.buf[1] == '\xBB' and L.buf[2] == '\xBF':
    inc(L.bufpos, 3)
    inc(L.lineStart, 3)

proc openBaseLexer(L: var TBaseLexer, inputstream: PLLStream, bufLen = 8192) =
  assert(bufLen > 0)
  L.bufpos = 0
  L.offsetBase = 0
  L.buf = newString(bufLen)
  L.sentinel = bufLen - 1
  L.lineStart = 0
  L.lineNumber = 1            # lines start at 1
  L.stream = inputstream
  fillBuffer(L)
  skipUTF8BOM(L)

proc getColNumber(L: TBaseLexer, pos: int): int =
  result = abs(pos - L.lineStart)

proc getCurrentLine(L: TBaseLexer, marker: bool = true): string =
  result = ""
  var i = L.lineStart
  while not (L.buf[i] in {CR, LF, EndOfFile}):
    result.add(L.buf[i])
    inc(i)
  result.add("\n")
  if marker:
    result.add(spaces(getColNumber(L, L.bufpos)) & '^' & "\n")