diff options
-rw-r--r-- | bouml/128002.diagram | 4 | ||||
-rw-r--r-- | bouml/a.prj | 49 | ||||
-rw-r--r-- | ranger/directory.py | 44 | ||||
-rw-r--r-- | ranger/environment.py | 2 | ||||
-rw-r--r-- | ranger/fsobject.py | 18 | ||||
-rw-r--r-- | ranger/wdisplay.py | 4 |
6 files changed, 76 insertions, 45 deletions
diff --git a/bouml/128002.diagram b/bouml/128002.diagram index 027d353a..11471f2c 100644 --- a/bouml/128002.diagram +++ b/bouml/128002.diagram @@ -66,11 +66,11 @@ classcanvas 135938 class_ref 136322 // FSObject end classcanvas 136066 class_ref 136450 // File draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default - xyz 83 455 2000 + xyz 91 420 2000 end classcanvas 136194 class_ref 136578 // Directory draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default - xyz 69 395 2005 + xyz 46 543 2005 end relationcanvas 129026 relation_ref 128002 // <association> decenter_end 288 diff --git a/bouml/a.prj b/bouml/a.prj index ff5419a6..bac9648a 100644 --- a/bouml/a.prj +++ b/bouml/a.prj @@ -1045,6 +1045,7 @@ ${docstring}${body} classrelation 152706 // <aggregation> relation_ref 150402 // <aggregation> end + end class 136450 "File" @@ -1085,6 +1086,54 @@ ${docstring}${members} classrelation_ref 152450 // <generalisation> b parent class_ref 136322 // FSObject end + + operation 138370 "load_content" + public explicit_return_type "" + nparams 0 + + + + python_def "${@}${static}${abstract}def ${name}${(}${)}: +${docstring}${body} +" + + end + + operation 138498 "move_pointer" + public explicit_return_type "" + nparams 0 + + + + python_def "${@}${static}${abstract}def ${name}${(}${)}: +${docstring}${body} +" + + end + + operation 138626 "move_pointer_to_file_path" + public explicit_return_type "" + nparams 0 + + + + python_def "${@}${static}${abstract}def ${name}${(}${)}: +${docstring}${body} +" + + end + + operation 138754 "correct_pointer" + public explicit_return_type "" + nparams 0 + + + + python_def "${@}${static}${abstract}def ${name}${(}${)}: +${docstring}${body} +" + + end end end add_operation_profile diff --git a/ranger/directory.py b/ranger/directory.py index 57df2e13..665f9f7d 100644 --- a/ranger/directory.py +++ b/ranger/directory.py @@ -22,15 +22,10 @@ class Directory(ranger.fsobject.FSObject): self.show_hidden = False self.old_show_hidden = self.show_hidden - def set_filter(self, string): - self.filter = string - self.load_content() - def load_content(self): from os.path import join, isdir, basename from os import listdir - self.stop_if_frozen() self.load_if_outdated() self.content_loaded = True @@ -42,8 +37,6 @@ class Directory(ranger.fsobject.FSObject): if isinstance(self.filter, str) and self.filter in fname: continue filenames.append(join(self.path, fname)) -# basenames = listdir(self.path) -# mapped = map(lambda name: join(self.path, name), basenames) self.scroll_offset = 0 self.filenames = filenames self.infostring = ' %d' % len(self.filenames) # update the infostring @@ -60,8 +53,10 @@ class Directory(ranger.fsobject.FSObject): self.files = files if len(self.files) > 0: - self.pointed_index = 0 - self.pointed_file = self.files[0] + if self.pointed_file is not None: + self.move_pointer_to_file_path(self.pointed_file) + if self.pointed_file is None: + self.move_pointer(absolute = 0) else: self.filenames = None self.files = None @@ -81,35 +76,42 @@ class Directory(ranger.fsobject.FSObject): i += relative self.pointed_index = i - self.fix_pointer() + self.correct_pointer() return self.pointed_file def move_pointer_to_file_path(self, path): + if path is None: return + try: path = path.path + except AttributeError: pass + self.load_content_once() i = 0 for f in self.files: if f.path == path: self.move_pointer(absolute = i) - return + return True i += 1 + return False - - def fix_pointer(self): + def correct_pointer(self): i = self.pointed_index - if i >= len(self.files): i = len(self.files) - 1 - if i < 0: i = 0 + + if i >= len(self.files): + i = len(self.files) - 1 + + if i < 0: + i = 0 + self.pointed_index = i self.pointed_file = self[i] def load_content_once(self): - self.stop_if_frozen() if not self.content_loaded: self.load_content() return True return False def load_content_if_outdated(self): - self.stop_if_frozen() if self.load_content_once(): return True if self.old_show_hidden != self.show_hidden: @@ -128,15 +130,9 @@ class Directory(ranger.fsobject.FSObject): def __len__(self): if not self.accessible: raise ranger.fsobject.NotLoadedYet() - return len(self.filenames) + return len(self.files) def __getitem__(self, key): if not self.accessible: raise ranger.fsobject.NotLoadedYet() return self.files[key] -if __name__ == '__main__': - d = Directory('.') - d.load_filenames() - print(d.filenames) - print(d[1]) - diff --git a/ranger/environment.py b/ranger/environment.py index d5678695..d6635e9f 100644 --- a/ranger/environment.py +++ b/ranger/environment.py @@ -52,7 +52,7 @@ class Environment(): last_path = path.path continue - log(( path.path, last_path )) +# log(( path.path, last_path )) path.move_pointer_to_file_path(last_path) last_path = path.path diff --git a/ranger/fsobject.py b/ranger/fsobject.py index 7a131891..099d3c5c 100644 --- a/ranger/fsobject.py +++ b/ranger/fsobject.py @@ -31,7 +31,6 @@ class FSObject(object): # load() reads useful information about the file from the file system # and caches it in instance attributes. def load(self): - self.stop_if_frozen() self.loaded = True import os @@ -66,14 +65,12 @@ class FSObject(object): self.accessible = False def load_once(self): - self.stop_if_frozen() if not self.loaded: self.load() return True return False def load_if_outdated(self): - self.stop_if_frozen() if self.load_once(): return True import os @@ -84,18 +81,3 @@ class FSObject(object): self.load() return True return False - - def clone(self): - clone = type(self)(self.path) - for key in iter(self.__dict__): - clone.__dict__[key] = self.__dict__[key] - return clone - - def frozen_clone(self): - clone = self.clone() - clone.frozen = True - return clone - - def stop_if_frozen(self): - if self.frozen: raise FrozenException('Cannot modify datastructure while it is frozen') - diff --git a/ranger/wdisplay.py b/ranger/wdisplay.py index d0962149..55c0c563 100644 --- a/ranger/wdisplay.py +++ b/ranger/wdisplay.py @@ -94,6 +94,10 @@ class WDisplay(ranger.widget.Widget): if halfwinsize < offset: return min( dirsize - winsize, max( 0, index - halfwinsize )) + if original > dirsize - winsize: + self.target.scroll_begin = dirsize - winsize + return self.get_scroll_begin() + if projected < upper_limit and projected > lower_limit: return original |