summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-26 10:51:43 +0200
committerhut <hut@lavabit.com>2010-04-26 20:56:27 +0200
commit26fbda26e39a4edc9705f71e5f16b5dd5ea96009 (patch)
tree90b9f7c58ea13a88a3379422e22ab3d4552999d3 /ranger
parentf31ad6f10fa5d3198b97bd4bcc57e4cf659bd1ca (diff)
downloadranger-26fbda26e39a4edc9705f71e5f16b5dd5ea96009.tar.gz
widgets.browsercolumn: fixed width-check for infostring
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index b193a523..e4ba4b64 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -304,7 +304,7 @@ class BrowserColumn(Pager):
 					x = self.wid - 1 - len(info)
 					if info is BAD_INFO:
 						bad_info_color = (x, len(str(info)))
-					if x > self.x:
+					if x > 0:
 						self.win.addstr(line, x, str(info) + ' ')
 			except:
 				# the drawing of the last string will cause an error
'>fa94f4d9 ^
294b2ab3 ^
fa94f4d9 ^


ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^

ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^


ceeb92d4 ^
fa94f4d9 ^

607ddf33 ^
fa94f4d9 ^
607ddf33 ^
fa94f4d9 ^

294b2ab3 ^
fa94f4d9 ^



ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^

ceeb92d4 ^
fa94f4d9 ^
fa94f4d9 ^
607ddf33 ^
fa94f4d9 ^



294b2ab3 ^
fa94f4d9 ^



ceeb92d4 ^
fa94f4d9 ^
fa94f4d9 ^



607ddf33 ^
fa94f4d9 ^
3d8b137c ^
607ddf33 ^


29cc15d6 ^
aaf61a53 ^
ada5eb55 ^
fa94f4d9 ^


607ddf33 ^
2d91279b ^
607ddf33 ^
4a48bedc ^
607ddf33 ^
3d8b137c ^
dd660682 ^
607ddf33 ^
2d91279b ^
607ddf33 ^
3d8b137c ^


607ddf33 ^


2d91279b ^
607ddf33 ^
4a48bedc ^
607ddf33 ^
2d91279b ^
dd660682 ^

607ddf33 ^


2d91279b ^
fa94f4d9 ^
4a48bedc ^
2d91279b ^
3d8b137c ^
d31037ff ^
607ddf33 ^

2d91279b ^
607ddf33 ^
d31037ff ^
fa94f4d9 ^
607ddf33 ^

2d91279b ^
607ddf33 ^
fa94f4d9 ^
607ddf33 ^
3d8b137c ^
607ddf33 ^



fa94f4d9 ^
607ddf33 ^
2d91279b ^
607ddf33 ^
fa94f4d9 ^
d31037ff ^
3d8b137c ^
d31037ff ^

607ddf33 ^
d31037ff ^
607ddf33 ^
3d8b137c ^

d31037ff ^
d31037ff ^



a01dd595 ^
6f65d591 ^
a01dd595 ^
607ddf33 ^
a01dd595 ^
294b2ab3 ^


6f65d591 ^
a01dd595 ^






11569717 ^
a01dd595 ^
294b2ab3 ^
a01dd595 ^
607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
a01dd595 ^


607ddf33 ^
a01dd595 ^

294b2ab3 ^
a01dd595 ^


607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^
a01dd595 ^



6f65d591 ^
a01dd595 ^
607ddf33 ^
a01dd595 ^
294b2ab3 ^


6f65d591 ^
a01dd595 ^






11569717 ^
a01dd595 ^
294b2ab3 ^
a01dd595 ^
607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
a01dd595 ^


607ddf33 ^
a01dd595 ^

294b2ab3 ^
a01dd595 ^


607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^
a01dd595 ^



6f65d591 ^
a01dd595 ^
607ddf33 ^
a01dd595 ^
294b2ab3 ^


6f65d591 ^
a01dd595 ^






11569717 ^

a01dd595 ^
294b2ab3 ^
a01dd595 ^
607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^
a01dd595 ^


607ddf33 ^
a01dd595 ^

294b2ab3 ^
a01dd595 ^


607ddf33 ^

ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^
a01dd595 ^



6f65d591 ^
a01dd595 ^
607ddf33 ^
a01dd595 ^
294b2ab3 ^


6f65d591 ^
a01dd595 ^







294b2ab3 ^
a01dd595 ^
607ddf33 ^

ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^


a01dd595 ^


607ddf33 ^
11569717 ^

a01dd595 ^

294b2ab3 ^
a01dd595 ^


607ddf33 ^
ceeb92d4 ^
607ddf33 ^


ceeb92d4 ^
607ddf33 ^
a01dd595 ^

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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345


                             
             
                                       
                                   


                                                                        
                                

                      




                                      
                                            


                                                        
                                                                                                                                                            
                                                        

                                                        
                                                                                                                                                            
                                                        


                                                        
                                                                                                                                                            

                                                        
                                                                     
                  
                    

       
                                              



                                                        
                                                                                                                                                            
                                                        

                                                        
                                                                                                                                                            
                                                        
   
                                                                     



                    
                                              



                                                        
                                                                                                                                                            
                                                        



                      
                           
   
                                                                       


                                                     
                                                     
                                                        
                    


   
                                                       
                                                                                              
             
             
                                    
                                                                   
                                          
                                                                     
                                                            
                            


                                                                                                      


                                                                                
                                                                                                              
             
             
                                                                                    
                                                  

                                        


                                    
                                                                              
             
             
                                                    
                                                    
   

                               
                                                                    
                                                  
   
   

                           
                                               
                                                          
     
                                                                   
                                                



                                                            
     
                                  
                                                                    
                                                                         
   
                        
                                                           

                                                             
                                            
   
                         

                                                          
                              



                                            
                                        
             
                                       
                                   
                          


                                                                        
                                






                                           
                   
   
                                            
                         
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            


                             
                    

       
                                              


                                                                          
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            
                                                        



                                            
             
                                       
                                   
                          


                                                                        
                                






                                           
                   
   
                                            
                         
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            


                             
                    

       
                                              


                                                                          
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            
                                                        



                                              
             
                                       
                                   
                          


                                                                        
                                






                                           

                   
   
                                            
                         
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            
                                                        


                             
                    

       
                                              


                                         

                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            
                                                        



                                         
             
                                       
                                   
                          


                                                                        
                                







                      
                                            
                         

                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            


                                                        


                                                            
                    

                   

       
                                              


                                  
                                                        
                                                                                                                                                            


                                                        
                                                                                                                                                            
                                                        

   
## deleting sandboxes

scenario deleting-sandboxes [
  local-scope
  trace-until 100/app  # trace too long
  assume-screen 50/width, 15/height
  assume-resources [
  ]
  env:&:environment <- new-programming-environment resources, screen, []
  render-all screen, env, render
  # run a few commands
  assume-console [
    type [divide-with-remainder 11, 3]
    press F4
    type [add 2, 2]
    press F4
  ]
  event-loop screen, console, env, resources
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
    .1   edit           copy           delete          .
    .divide-with-remainder 11, 3                       .
    .3                                                 .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
  # delete second sandbox by clicking on left edge of 'delete' button
  assume-console [
    left-click 7, 34
  ]
  run [
    event-loop screen, console, env, resources
  ]
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
  # delete first sandbox by clicking at right edge of 'delete' button
  assume-console [
    left-click 3, 49
  ]
  run [
    event-loop screen, console, env, resources
  ]
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
]

after <global-touch> [
  # support 'delete' button
  {
    delete?:bool <- should-attempt-delete? click-row, click-column, env
    break-unless delete?
    delete?, env <- try-delete-sandbox click-row, env
    break-unless delete?
    screen <- render-sandbox-side screen, env, render
    screen <- update-cursor screen, current-sandbox, env
    loop +next-event
  }
]

# some preconditions for attempting to delete a sandbox
def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [
  local-scope
  load-inputs
  # are we below the sandbox editor?
  click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env
  return-unless click-sandbox-area?, false
  # narrower, is the click in the columns spanning the 'copy' button?
  first-sandbox:&:editor <- get *env, current-sandbox:offset
  assert first-sandbox, [!!]
  sandbox-left-margin:num <- get *first-sandbox, left:offset
  sandbox-right-margin:num <- get *first-sandbox, right:offset
  _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
  result <- within-range? click-column, delete-button-left, sandbox-right-margin
]

def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [
  local-scope
  load-inputs
  # identify the sandbox to delete, if the click was actually on the 'delete' button
  sandbox:&:sandbox <- find-sandbox env, click-row
  return-unless sandbox, false
  clicked-on-delete-button? <- copy true
  env <- delete-sandbox env, sandbox
]

def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [
  local-scope
  load-inputs
  curr-sandbox:&:sandbox <- get *env, sandbox:offset
  first-sandbox?:bool <- equal curr-sandbox, sandbox
  {
    # first sandbox? pop
    break-unless first-sandbox?
    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
    *env <- put *env, sandbox:offset, next-sandbox
  }
  {
    # not first sandbox?
    break-if first-sandbox?
    prev-sandbox:&:sandbox <- copy curr-sandbox
    curr-sandbox <- get *curr-sandbox, next-sandbox:offset
    {
      assert curr-sandbox, [sandbox not found! something is wrong.]
      found?:bool <- equal curr-sandbox, sandbox
      break-if found?
      prev-sandbox <- copy curr-sandbox
      curr-sandbox <- get *curr-sandbox, next-sandbox:offset
      loop
    }
    # snip sandbox out of its list
    next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
    *prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox
  }
  # update sandbox count
  sandbox-count:num <- get *env, number-of-sandboxes:offset
  sandbox-count <- subtract sandbox-count, 1
  *env <- put *env, number-of-sandboxes:offset, sandbox-count
  # reset scroll if deleted sandbox was last
  {
    break-if next-sandbox
    render-from:num <- get *env, render-from:offset
    reset-scroll?:bool <- equal render-from, sandbox-count
    break-unless reset-scroll?
    *env <- put *env, render-from:offset, -1
  }
]

scenario deleting-sandbox-after-scroll [
  local-scope
  trace-until 100/app  # trace too long
  assume-screen 50/width, 10/height
  # initialize environment
  assume-resources [
  ]
  env:&:environment <- new-programming-environment resources, screen, []
  render-all screen, env, render
  # create 2 sandboxes and scroll to second
  assume-console [
    press ctrl-n
    type [add 2, 2]
    press F4
    type [add 1, 1]
    press F4
    press page-down
  ]
  event-loop screen, console, env, resources
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 1, 1                                          .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .1   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
  ]
  # delete the second sandbox
  assume-console [
    left-click 6, 34
  ]
  run [
    event-loop screen, console, env, resources
  ]
  # second sandbox shows in editor; scroll resets to display first sandbox
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 1, 1                                          .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
]

scenario deleting-top-sandbox-after-scroll [
  local-scope
  trace-until 100/app  # trace too long
  assume-screen 50/width, 10/height
  # initialize environment
  assume-resources [
  ]
  env:&:environment <- new-programming-environment resources, screen, []
  render-all screen, env, render
  # create 2 sandboxes and scroll to second
  assume-console [
    press ctrl-n
    type [add 2, 2]
    press F4
    type [add 1, 1]
    press F4
    press page-down
  ]
  event-loop screen, console, env, resources
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 1, 1                                          .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .1   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
  ]
  # delete the second sandbox
  assume-console [
    left-click 2, 34
  ]
  run [
    event-loop screen, console, env, resources
  ]
  # second sandbox shows in editor; scroll resets to display first sandbox
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
]

scenario deleting-final-sandbox-after-scroll [
  local-scope
  trace-until 100/app  # trace too long
  assume-screen 50/width, 10/height
  # initialize environment
  assume-resources [
  ]
  env:&:environment <- new-programming-environment resources, screen, []
  render-all screen, env, render
  # create 2 sandboxes and scroll to second
  assume-console [
    press ctrl-n
    type [add 2, 2]
    press F4
    type [add 1, 1]
    press F4
    press page-down
    press page-down
  ]
  event-loop screen, console, env, resources
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .1   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
  # delete the second sandbox
  assume-console [
    left-click 2, 34
  ]
  run [
    event-loop screen, console, env, resources
  ]
  # implicitly scroll up to first sandbox
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 1, 1                                          .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
]

scenario deleting-updates-sandbox-count [
  local-scope
  trace-until 100/app  # trace too long
  assume-screen 50/width, 10/height
  # initialize environment
  assume-resources [
  ]
  env:&:environment <- new-programming-environment resources, screen, []
  render-all screen, env, render
  # create 2 sandboxes
  assume-console [
    press ctrl-n
    type [add 2, 2]
    press F4
    type [add 1, 1]
    press F4
  ]
  event-loop screen, console, env, resources
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 1, 1                                          .
    .2                                                 .
    .──────────────────────────────────────────────────.
    .1   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
  ]
  # delete the second sandbox, then try to scroll down twice
  assume-console [
    left-click 3, 34
    press page-down
    press page-down
  ]
  run [
    event-loop screen, console, env, resources
  ]
  # shouldn't go past last sandbox
  screen-should-contain [
    .                               run (F4)           .
    .──────────────────────────────────────────────────.
    .0   edit           copy           delete          .
    .add 2, 2                                          .
    .4                                                 .
    .──────────────────────────────────────────────────.
    .                                                  .
  ]
]