summary refs log tree commit diff stats
path: root/ranger
Commit message (Expand)AuthorAgeFilesLines
* removed copyright notice from trivial files (__init__.py's)hut2011-09-294-63/+6
* colorschemes/default: updatedhut2011-09-292-16/+1
* core.actions: replaced internal help with 'man ranger'hut2011-09-2910-938/+10
* core.runner: replaced waitpid_no_intr by process.wait()hut2011-09-292-32/+1
* core.main: added --list-unused-keys optionhut2011-09-293-2/+18
* added experimental plugin systemhut2011-09-281-0/+25
* defaults.commands: optimization of touch commandhut2011-09-271-1/+1
* documented and improved DaPangus' changeshut2011-09-251-0/+3
* Merge branch 'rename' of https://github.com/DaPangus/rangerhut2011-09-252-4/+13
|\
| * Merge remote-tracking branch 'upstream/master' into renameDavid Pugnasse2011-08-105-24/+30
| |\
| * | improved renamingDavid Pugnasse2011-08-102-4/+13
* | | extended manpage and fixed {load,save}_copy_buffer commandshut2011-09-251-4/+9
* | | help.console: typohut2011-09-251-1/+1
* | | defaults.commands.py: added :bulkrename command from wikihut2011-09-252-0/+59
* | | slight changes to the settingshut2011-09-242-1/+2
* | | core.actions: Added flag "c" + documentationhut2011-09-243-1/+9
* | | Merge branch 'master' of ssh://repo.or.cz/srv/git/rangerhut2011-09-233-10/+15
|\ \ \
| * | | help.console: corrected numbershut2011-09-231-3/+3
| * | | use errno.EEXISTPino Toscano2011-09-171-1/+2
| * | | gui.widgets.pager: fixed crashhut2011-09-141-6/+10
* | | | gui.widgets.console: fixed error canceling nonexistent commandhut2011-09-171-3/+4
|/ / /
* | | add cycling by mtime and atimehut2011-09-081-1/+1
* | | core.actions: throw some signals before and after executing fileshut2011-09-081-1/+5
* | | defaults/keys: added sorting by atimehut2011-08-262-1/+3
* | | defaults/keys: use = key for octal chmoddinghut2011-08-231-5/+9
* | | defaults/keys: Added hint for sorting by ctimehut2011-08-231-1/+1
* | | defaults/keys: added hints for chmod keyshut2011-08-231-0/+9
* | | defaults/keys: add shortcuts for chmod: +ow = chmod o+w, etchut2011-08-231-0/+8
| |/ |/|
* | Merge https://github.com/tonttu/rangerhut2011-08-101-1/+1
|\ \
| * | Fixed #33227, pager crashed when trying to read non-readable fileRiku Palomäki2011-05-041-1/+1
* | | Merge branch 'atool' of https://github.com/radhermit/rangerhut2011-08-101-2/+3
|\ \ \
| * | | data/scope.sh: show compressed text files with atoolTim Harder2011-07-181-2/+3
* | | | container.tags: replaced the word "mark" with "tag"hut2011-08-103-20/+20
* | | | container.tags: modified DaPangus' patch for more compatibilityhut2011-08-101-6/+11
| |_|/ |/| |
* | | Custom tagsDavid Pugnasse2011-08-105-21/+51
* | | defaults/keys.py: added sorting by ctimehut2011-08-032-0/+2
* | | data/mime.types: added webm typehut2011-08-031-0/+1
|/ /
* | api.commands: implemented command.cancel()hut2011-05-203-3/+14
* | ranger/gui/ui: Fixed issues with ALT keyhut2011-05-192-3/+10
* | added option "display_tags_in_all_columns"hut2011-05-083-4/+11
* | defaults/keys: improved hintshut2011-05-082-8/+17
* | data/scope.sh: Added bittorrent previewhut2011-05-081-0/+4
* | core.main: Forbid piping things into rangerhut2011-05-071-0/+5
* | data/mime.types: Added wavpackhut2011-05-071-0/+1
|/
* core.loader: Fix blocking when using interactive scripts in scope.shhut2011-04-272-3/+5
* Merge branch 'stable'hut2011-04-261-1/+1
|\
| * This gonna be cool once it's finished v1.4.3hut2011-04-051-1/+1
| * defaults/options.py: hide __cache__ folderhut2011-04-051-1/+1
| * core.fm: fixed mimetype bughut2011-04-031-4/+4
| * extended apps.pyhut2011-04-031-1/+2
class="n">hei = 0 self.paryx = (0, 0) self.parent = None self._old_visible = self.visible if win is not None: if isinstance(self, UI): self.win = win else: self.win = win.derwin(1, 1, 0, 0) def __nonzero__(self): """Always True""" return True def __contains__(self, item): """Is item inside the boundaries? item can be an iterable like [y, x] or an object with x and y methods. """ try: y, x = item.y, item.x except AttributeError: try: y, x = item except (ValueError, TypeError): return False return self.contains_point(y, x) def draw(self): """ Draw the object. Called on every main iteration if visible. Containers should call draw() on their contained objects here. Override this! """ def destroy(self): """Called when the object is destroyed. Override this! """ def contains_point(self, y, x): """ Test whether the point (with absolute coordinates) lies within the boundaries of this object. """ return (x >= self.x and x < self.x + self.wid) and \ (y >= self.y and y < self.y + self.hei) def click(self, event): """Called when a mouse key is pressed and self.focused is True. Override this! """ pass def press(self, key): """Called when a key is pressed and self.focused is True. Override this! """ pass def poke(self): """Called before drawing, even if invisible""" if self._old_visible != self.visible: self._old_visible = self.visible self.need_redraw = True if not self.visible: self.win.erase() def finalize(self): """Called after every displayable is done drawing. Override this! """ pass def resize(self, y, x, hei=None, wid=None): """Resize the widget""" do_move = False try: maxy, maxx = self.env.termsize except TypeError: pass else: if hei is None: hei = maxy - y if wid is None: wid = maxx - x if x < 0 or y < 0: raise ValueError("Starting point below zero!") #if wid < 1 or hei < 1: # raise OutOfBoundsException("WID and HEI must be >=1!") if x + wid > maxx and y + hei > maxy: raise ValueError("X and Y out of bounds!") if x + wid > maxx: raise ValueError("X out of bounds!") if y + hei > maxy: raise ValueError("Y out of bounds!") window_is_cleared = False if hei != self.hei or wid != self.wid: #log("resizing " + str(self)) self.win.erase() self.need_redraw = True window_is_cleared = True try: self.win.resize(hei, wid) except: # Not enough space for resizing... try: self.win.mvderwin(0, 0) do_move = True self.win.resize(hei, wid) except: pass #raise ValueError("Resizing Failed!") self.hei, self.wid = self.win.getmaxyx() if do_move or y != self.paryx[0] or x != self.paryx[1]: if not window_is_cleared: self.win.erase() self.need_redraw = True #log("moving " + str(self)) try: self.win.mvderwin(y, x) except: pass self.paryx = self.win.getparyx() self.y, self.x = self.paryx if self.parent: self.y += self.parent.y self.x += self.parent.x def __str__(self): return self.__class__.__name__ class DisplayableContainer(Displayable): """ DisplayableContainers are Displayables which contain other Displayables. This is also an abstract class. The methods draw, poke, finalize, click, press and destroy are extended here and will recursively call the function on all contained objects. New methods: add_child(object) -- add the object to the container. remove_child(object) -- remove the object from the container. New attributes: container -- a list with all contained objects (rw) """ def __init__(self, win, env=None, fm=None, settings=None): if env is not None: self.env = env if fm is not None: self.fm = fm if settings is not None: self.settings = settings self.container = [] Displayable.__init__(self, win) # ------------------------------------ extended or overidden methods def poke(self): """Recursively called on objects in container""" Displayable.poke(self) for displayable in self.container: displayable.poke() def draw(self): """Recursively called on visible objects in container""" for displayable in self.container: if self.need_redraw: displayable.need_redraw = True if displayable.visible: displayable.draw() self.need_redraw = False def finalize(self): """Recursively called on visible objects in container""" for displayable in self.container: if displayable.visible: displayable.finalize() def press(self, key): """Recursively called on objects in container""" focused_obj = self._get_focused_obj() if focused_obj: focused_obj.press(key) return True return False def click(self, event): """Recursively called on objects in container""" focused_obj = self._get_focused_obj() if focused_obj and focused_obj.click(event): return True for displayable in self.container: if event in displayable: if displayable.click(event): return True return False def destroy(self): """Recursively called on objects in container""" for displayable in self.container: displayable.destroy() # ----------------------------------------------- new methods def add_child(self, obj): """Add the objects to the container.""" if obj.parent: obj.parent.remove_child(obj) self.container.append(obj) obj.parent = self def remove_child(self, obj): """Remove the object from the container.""" try: container.remove(obj) except ValueError: pass else: obj.parent = None def _get_focused_obj(self): # Finds a focused displayable object in the container. for displayable in self.container: if displayable.focused: return displayable try: obj = displayable._get_focused_obj() except AttributeError: pass else: if obj is not None: return obj return None