summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/config/rc.conf8
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/gui/displayable.py3
-rw-r--r--ranger/gui/ui.py19
4 files changed, 21 insertions, 10 deletions
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 25972904..993f0563 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -19,6 +19,13 @@
 # == Options
 # ===================================================================
 
+# Which viewmode should be used?  Possible values are:
+#     miller: Use miller columns which show multiple levels of the hierarchy
+#     multipane: Midnight-commander like multipane view showing all tabs next
+#                to each other
+set viewmode miller
+#set viewmode multipane
+
 # How many columns are there, and what are their relative widths?
 set column_ratios 1,3,4
 
@@ -235,6 +242,7 @@ map <C-r> reset
 map <C-l> redraw_window
 map <C-c> abort
 map <esc> change_mode normal
+map ~ set viewmode!
 
 map i display_file
 map ? help
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 2a673588..14ff9bca 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -73,6 +73,7 @@ ALLOWED_VALUES = {
     'vcs_backend_git': ['enabled', 'local', 'disabled'],
     'vcs_backend_hg': ['enabled', 'local', 'disabled'],
     'vcs_backend_svn': ['enabled', 'local', 'disabled'],
+    'viewmode': ['miller', 'multipane'],
 }
 
 DEFAULT_VALUES = {
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 8415b82c..c6e21d54 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -95,7 +95,8 @@ class Displayable(FileManagerAware, CursesShortcuts):
 
     def destroy(self):
         """Called when the object is destroyed."""
-        del self.win
+        if hasattr(self, 'win'):
+            del self.win
 
     def contains_point(self, y, x):
         """Test whether the point lies inside this object.
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 67db51d3..14d6f247 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -47,7 +47,6 @@ class UI(DisplayableContainer):
         self.keymaps = KeyMaps(self.keybuffer)
         self.redrawlock = threading.Event()
         self.redrawlock.set()
-        self._browser_viewmodes = dict()
 
         if fm is not None:
             self.fm = fm
@@ -242,8 +241,8 @@ class UI(DisplayableContainer):
         # Create the browser view
         self.settings.signal_bind('setopt.viewmode', self._set_viewmode)
         self._viewmode = None
-        self.viewmode = 'miller'  # this line sets self.browser implicitly
-                                  # through the signal handler bound above
+        # The following line sets self.browser implicitly through the signal
+        self.viewmode = self.settings.viewmode
         self.add_child(self.browser)
 
         # Create the process manager
@@ -434,15 +433,17 @@ class UI(DisplayableContainer):
         if value in self.ALLOWED_VIEWMODES:
             if self._viewmode != value:
                 self._viewmode = value
+                resize = False
                 if hasattr(self, 'browser'):
+                    old_size = self.browser.y, self.browser.x, self.browser.hei, self.browser.wid
                     self.remove_child(self.browser)
-                if value in self._browser_viewmodes:
-                    self.browser = self._browser_viewmodes[value]
-                else:
-                    browser = self._viewmode_to_class(value)(self.win)
-                    self.browser = self._browser_viewmodes[value] = browser
-                    self.browser.resize(self.y, self.x, self.hei, self.wid)
+                    self.browser.destroy()
+                    resize = True
+
+                self.browser = self._viewmode_to_class(value)(self.win)
                 self.add_child(self.browser)
+                if resize:
+                    self.browser.resize(*old_size)
         else:
             raise ValueError("Attempting to set invalid viewmode `%s`, should "
                     "be one of `%s`." % (value, "`, `".join(self.ALLOWED_VIEWMODES)))