summary refs log blame commit diff stats
path: root/doc/pydoc/ranger.container.html
blob: 4957d18ac644e0af3930f6ca4c0972eefa856813 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
an>State.cursor1.line].data offset = find(curr_line, State.search_term, --[[from start]] nil, --[[literal]] true) local pos = utf8.len(curr_line, 1, offset) if pos and pos < State.cursor1.pos then State.cursor1.pos = pos end end if offset == nil then State.cursor1.line = State.search_backup.cursor.line State.cursor1.pos = State.search_backup.cursor.pos State.screen_top1.line = State.search_backup.screen_top.line State.screen_top1.pos = State.search_backup.screen_top.pos end local screen_bottom1 = Text.screen_bottom1(State) if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(screen_bottom1, State.cursor1) then State.screen_top1.line = State.cursor1.line local pos = Text.pos_at_start_of_screen_line(State, State.cursor1) State.screen_top1.pos = pos end end function Text.search_previous(State) if #State.search_term == 0 then return end -- search current line before cursor local curr_pos = State.cursor1.pos local curr_line = State.lines[State.cursor1.line].data local curr_offset = Text.offset(curr_line, curr_pos) local offset = rfind(curr_line, State.search_term, curr_offset-1, --[[literal]] true) if offset then State.cursor1.pos = utf8.len(curr_line, 1, offset) end if offset == nil then -- search lines above cursor for i=State.cursor1.line-1,1,-1 do local curr_line = State.lines[i].data offset = rfind(curr_line, State.search_term, --[[from end]] nil, --[[literal]] true) if offset then State.cursor1 = {line=i, pos=utf8.len(curr_line, 1, offset)} break end end end if offset == nil then -- wrap around for i=#State.lines,State.cursor1.line+1,-1 do local curr_line = State.lines[i].data offset = rfind(curr_line, State.search_term, --[[from end]] nil, --[[literal]] true) if offset then State.cursor1 = {line=i, pos=utf8.len(curr_line, 1, offset)} break end end end if offset == nil then -- search current line after cursor local curr_line = State.lines[State.cursor1.line].data offset = rfind(curr_line, State.search_term, --[[from end]] nil, --[[literal]] true) local pos = utf8.len(curr_line, 1, offset) if pos and pos > State.cursor1.pos then State.cursor1.pos = pos end end if offset == nil then State.cursor1.line = State.search_backup.cursor.line State.cursor1.pos = State.search_backup.cursor.pos State.screen_top1.line = State.search_backup.screen_top.line State.screen_top1.pos = State.search_backup.screen_top.pos end local screen_bottom1 = Text.screen_bottom1(State) if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(screen_bottom1, State.cursor1) then State.screen_top1.line = State.cursor1.line local pos = Text.pos_at_start_of_screen_line(State, State.cursor1) State.screen_top1.pos = pos end end function find(s, pat, i, plain) if s == nil then return end return s:find(pat, i, plain) end -- TODO: avoid the expensive reverse() operations -- Particularly if we only care about literal matches, we don't need all of string.find function rfind(s, pat, i, plain) if s == nil then return end if #pat == 0 then return #s end local rs = s:reverse() local rpat = pat:reverse() if i == nil then i = #s end local ri = #s - i + 1 local rendpos = rs:find(rpat, ri, plain) if rendpos == nil then return nil end local endpos = #s - rendpos + 1 assert (endpos >= #pat, ('rfind: endpos %d should be >= #pat %d at this point'):format(endpos, #pat)) return endpos-#pat+1 end function test_rfind() check_eq(rfind('abc', ''), 3, 'empty pattern') check_eq(rfind('abc', 'c'), 3, 'final char') check_eq(rfind('acbc', 'c', 3), 2, 'previous char') check_nil(rfind('abc', 'd'), 'missing char') check_nil(rfind('abc', 'c', 2), 'no more char') end
><a name="BrowserView">class <strong>BrowserView</strong></a>(<a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>, <a href="ranger.gui.displayable.html#DisplayableContainer">ranger.gui.displayable.DisplayableContainer</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td> <td width="100%"><dl><dt>Method resolution order:</dt> <dd><a href="ranger.gui.widgets.browserview.html#BrowserView">BrowserView</a></dd> <dd><a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a></dd> <dd><a href="ranger.gui.displayable.html#DisplayableContainer">ranger.gui.displayable.DisplayableContainer</a></dd> <dd><a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a></dd> <dd><a href="ranger.shared.html#EnvironmentAware">ranger.shared.EnvironmentAware</a></dd> <dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd> <dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd> <dd><a href="ranger.gui.curses_shortcuts.html#CursesShortcuts">ranger.gui.curses_shortcuts.CursesShortcuts</a></dd> <dd><a href="ranger.shared.settings.html#SettingsAware">ranger.shared.settings.SettingsAware</a></dd> <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> </dl> <hr> Methods defined here:<br> <dl><dt><a name="BrowserView-__init__"><strong>__init__</strong></a>(self, win, ratios, preview<font color="#909090">=True</font>)</dt></dl> <dl><dt><a name="BrowserView-click"><strong>click</strong></a>(self, event)</dt></dl> <dl><dt><a name="BrowserView-close_pager"><strong>close_pager</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-draw"><strong>draw</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-finalize"><strong>finalize</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-open_pager"><strong>open_pager</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-poke"><strong>poke</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-resize"><strong>resize</strong></a>(self, y, x, hei, wid)</dt><dd><tt>Resize&nbsp;all&nbsp;the&nbsp;columns&nbsp;according&nbsp;to&nbsp;the&nbsp;given&nbsp;ratio</tt></dd></dl> <hr> Data and other attributes defined here:<br> <dl><dt><strong>need_clear</strong> = False</dl> <dl><dt><strong>preview</strong> = True</dl> <dl><dt><strong>preview_available</strong> = True</dl> <dl><dt><strong>ratios</strong> = None</dl> <dl><dt><strong>stretch_ratios</strong> = None</dl> <hr> Methods inherited from <a href="ranger.gui.displayable.html#DisplayableContainer">ranger.gui.displayable.DisplayableContainer</a>:<br> <dl><dt><a name="BrowserView-add_child"><strong>add_child</strong></a>(self, obj)</dt><dd><tt>Add&nbsp;the&nbsp;objects&nbsp;to&nbsp;the&nbsp;container.</tt></dd></dl> <dl><dt><a name="BrowserView-destroy"><strong>destroy</strong></a>(self)</dt><dd><tt>Recursively&nbsp;called&nbsp;on&nbsp;objects&nbsp;in&nbsp;container</tt></dd></dl> <dl><dt><a name="BrowserView-press"><strong>press</strong></a>(self, key)</dt><dd><tt>Recursively&nbsp;called&nbsp;on&nbsp;objects&nbsp;in&nbsp;container</tt></dd></dl> <dl><dt><a name="BrowserView-remove_child"><strong>remove_child</strong></a>(self, obj)</dt><dd><tt>Remove&nbsp;the&nbsp;object&nbsp;from&nbsp;the&nbsp;container.</tt></dd></dl> <hr> Methods inherited from <a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a>:<br> <dl><dt><a name="BrowserView-__bool__"><strong>__bool__</strong></a> = __nonzero__(self)</dt><dd><tt>Always&nbsp;True</tt></dd></dl> <dl><dt><a name="BrowserView-__contains__"><strong>__contains__</strong></a>(self, item)</dt><dd><tt>Is&nbsp;item&nbsp;inside&nbsp;the&nbsp;boundaries?<br> item&nbsp;can&nbsp;be&nbsp;an&nbsp;iterable&nbsp;like&nbsp;[y,&nbsp;x]&nbsp;or&nbsp;an&nbsp;object&nbsp;with&nbsp;x&nbsp;and&nbsp;y&nbsp;methods.</tt></dd></dl> <dl><dt><a name="BrowserView-__nonzero__"><strong>__nonzero__</strong></a>(self)</dt><dd><tt>Always&nbsp;True</tt></dd></dl> <dl><dt><a name="BrowserView-__str__"><strong>__str__</strong></a>(self)</dt></dl> <dl><dt><a name="BrowserView-contains_point"><strong>contains_point</strong></a>(self, y, x)</dt><dd><tt>Test&nbsp;whether&nbsp;the&nbsp;point&nbsp;(with&nbsp;absolute&nbsp;coordinates)&nbsp;lies<br> within&nbsp;the&nbsp;boundaries&nbsp;of&nbsp;this&nbsp;object.</tt></dd></dl> <hr> Data and other attributes inherited from <a href="ranger.shared.html#EnvironmentAware">ranger.shared.EnvironmentAware</a>:<br> <dl><dt><strong>env</strong> = None</dl> <hr> Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br> <dl><dt><strong>fm</strong> = None</dl> <hr> Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd> </dl> <hr> Methods inherited from <a href="ranger.gui.curses_shortcuts.html#CursesShortcuts">ranger.gui.curses_shortcuts.CursesShortcuts</a>:<br> <dl><dt><a name="BrowserView-addnstr"><strong>addnstr</strong></a>(self, *args)</dt></dl> <dl><dt><a name="BrowserView-addstr"><strong>addstr</strong></a>(self, *args)</dt></dl> <dl><dt><a name="BrowserView-color"><strong>color</strong></a>(self, *keys)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;from&nbsp;now&nbsp;on.</tt></dd></dl> <dl><dt><a name="BrowserView-color_at"><strong>color_at</strong></a>(self, y, x, wid, *keys)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;at&nbsp;the&nbsp;specified&nbsp;position</tt></dd></dl> <dl><dt><a name="BrowserView-color_reset"><strong>color_reset</strong></a>(self)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;to&nbsp;the&nbsp;default&nbsp;colors</tt></dd></dl> <hr> Data and other attributes inherited from <a href="ranger.shared.settings.html#SettingsAware">ranger.shared.settings.SettingsAware</a>:<br> <dl><dt><strong>settings</strong> = {}</dl> </td></tr></table></td></tr></table> </body></html>