fe0302428a49

Add initial settings.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 13 Jun 2011 16:13:44 -0400
parents 2b0e5d916649
children 437b4b34d319
branches/tags (none)
files doc/threesome.txt plugin/threesome.vim plugin/threesomelib/init.py plugin/threesomelib/modes.py plugin/threesomelib/settings.py

Changes

--- a/doc/threesome.txt	Mon Jun 13 15:48:03 2011 -0400
+++ b/doc/threesome.txt	Mon Jun 13 16:13:44 2011 -0400
@@ -25,29 +25,34 @@
 ==============================================================================
 CONTENTS                                                  *Threesome-contents*
 
-    1. Version Control Integration .... |ThreesomeVCS|
-        1.1 Mercurial ................. |ThreesomeVCS-hg|
-        1.2 Git ....................... |ThreesomeVCS-git|
-    2. Basic Usage .................... |ThreesomeUsage|
-        2.1 Files ..................... |ThreesomeUsage-files|
-        2.2 Modes ..................... |ThreesomeUsage-modes|
-    3. Key Bindings ................... |ThreesomeKeys|
-        3.1 Mode Selection Keys ....... |ThreesomeKeys-mode|
-        3.2 File Selection Keys ....... |ThreesomeKeys-file|
-        3.3 Other Keys ................ |ThreesomeKeys-other|
-    4. Modes .......................... |ThreesomeModes|
-        4.1 Grid ...................... |ThreesomeModes-grid|
-        4.2 Loupe ..................... |ThreesomeModes-loupe|
-        4.3 Compare ................... |ThreesomeModes-compare|
-        4.4 Path ...................... |ThreesomeModes-path|
-    5. Configuration .................. |ThreesomeConfig|
-        5.1 threesome_debug ........... |ThreesomeConfig-debug|
-        5.1 threesome_disable ......... |ThreesomeConfig-disable|
-    6. License ........................ |ThreesomeLicense|
-    7. Bugs ........................... |ThreesomeBugs|
-    8. Contributing ................... |ThreesomeContributing|
-    9. Changelog ...................... |ThreesomeChangelog|
-   10. Credits ........................ |ThreesomeCredits|
+    1. Version Control Integration ............ |ThreesomeVCS|
+        1.1 Mercurial ......................... |ThreesomeVCS-hg|
+        1.2 Git ............................... |ThreesomeVCS-git|
+    2. Basic Usage ............................ |ThreesomeUsage|
+        2.1 Files ............................. |ThreesomeUsage-files|
+        2.2 Modes ............................. |ThreesomeUsage-modes|
+    3. Key Bindings ........................... |ThreesomeKeys|
+        3.1 Mode Selection Keys ............... |ThreesomeKeys-mode|
+        3.2 File Selection Keys ............... |ThreesomeKeys-file|
+        3.3 Other Keys ........................ |ThreesomeKeys-other|
+    4. Modes .................................. |ThreesomeModes|
+        4.1 Grid .............................. |ThreesomeModes-grid|
+        4.2 Loupe ............................. |ThreesomeModes-loupe|
+        4.3 Compare ........................... |ThreesomeModes-compare|
+        4.4 Path .............................. |ThreesomeModes-path|
+    5. Configuration .......................... |ThreesomeConfig|
+        5.1 threesome_debug ................... |ThreesomeConfig-debug|
+        5.2 threesome_disable ................. |ThreesomeConfig-disable|
+        5.3 threesome_initial_layout_grid ..... |ThreesomeConfig-il_grid|
+        5.4 threesome_initial_layout_loupe .... |ThreesomeConfig-il_loupe|
+        5.5 threesome_initial_layout_compare .. |ThreesomeConfig-il_compare|
+        5.6 threesome_initial_layout_path ..... |ThreesomeConfig-il_path|
+        5.7 threesome_initial_mode ............ |ThreesomeConfig-initial_mode|
+    6. License ................................ |ThreesomeLicense|
+    7. Bugs ................................... |ThreesomeBugs|
+    8. Contributing ........................... |ThreesomeContributing|
+    9. Changelog .............................. |ThreesomeChangelog|
+   10. Credits ................................ |ThreesomeCredits|
 
 
 ==============================================================================
@@ -408,7 +413,9 @@
 You can tweak the behavior of Threesome by setting a few variables in your
 |vimrc| file. For example: >
 
-    let g:threesome_disable = 1
+    let g:threesome_initial_mode = "compare"
+    let g:threesome_initial_layout_grid = 2
+    let g:threesome_initial_layout_compare = 1
 
 ------------------------------------------------------------------------------
 5.1 g:threesome_debug                                  *ThreesomeConfig-debug*
@@ -427,6 +434,51 @@
 
 Default: 0 (Threesome is enabled as usual)
 
+------------------------------------------------------------------------------
+5.3 g:threesome_initial_layout_grid                  *ThreesomeConfig-il_grid*
+
+Set this to change the layout the grid mode starts in.
+
+Options: 0, 1, or 2
+
+Default: 0
+
+------------------------------------------------------------------------------
+5.4 g:threesome_initial_layout_loupe                *ThreesomeConfig-il_loupe*
+
+Set this to change the layout the loupe mode starts in.
+
+Options: 0
+
+Default: 0
+
+------------------------------------------------------------------------------
+5.5 g:threesome_initial_layout_compare            *ThreesomeConfig-il_compare*
+
+Set this to change the layout the compare mode starts in.
+
+Options: 0 or 1
+
+Default: 0
+
+------------------------------------------------------------------------------
+5.6 g:threesome_initial_layout_path                  *ThreesomeConfig-il_path*
+
+Set this to change the layout the path mode starts in.
+
+Options: 0 or 1
+
+Default: 0
+
+------------------------------------------------------------------------------
+5.7 g:threesome_initial_mode                    *ThreesomeConfig-initial_mode*
+
+Set this to change the mode Threesome initially starts up in.
+
+Options: "grid", "loupe", "compare", or "path"
+
+Default: "grid"
+
 ==============================================================================
 6. License                                                  *ThreesomeLicense*
 
--- a/plugin/threesome.vim	Mon Jun 13 15:48:03 2011 -0400
+++ b/plugin/threesome.vim	Mon Jun 13 16:13:44 2011 -0400
@@ -56,6 +56,21 @@
 if !exists('g:threesome_disable') " {{{
     let g:threesome_disable = 0
 endif " }}}
+if !exists('g:threesome_initial_mode') " {{{
+    let g:threesome_initial_mode = 'grid'
+endif " }}}
+if !exists('g:threesome_initial_layout_grid') " {{{
+    let g:threesome_initial_layout_grid = 0
+endif " }}}
+if !exists('g:threesome_initial_layout_loupe') " {{{
+    let g:threesome_initial_layout_loupe = 0
+endif " }}}
+if !exists('g:threesome_initial_layout_compare') " {{{
+    let g:threesome_initial_layout_compare = 0
+endif " }}}
+if !exists('g:threesome_initial_layout_path') " {{{
+    let g:threesome_initial_layout_path = 0
+endif " }}}
 
 "}}}
 
--- a/plugin/threesomelib/init.py	Mon Jun 13 15:48:03 2011 -0400
+++ b/plugin/threesomelib/init.py	Mon Jun 13 16:13:44 2011 -0400
@@ -1,5 +1,6 @@
 import vim
 import modes
+from settings import setting
 from util import buffers, keys, windows
 
 
@@ -67,7 +68,12 @@
     process_result()
     setlocal_buffers()
     bind_global_keys()
-    modes.current_mode = modes.grid
+
+    initial_mode = setting('initial_mode', 'grid').lower()
+    if initial_mode not in ['grid', 'loupe', 'compare', 'path']:
+        initial_mode = 'grid'
+
+    modes.current_mode = getattr(modes, initial_mode)
     modes.current_mode.activate()
 
 
--- a/plugin/threesomelib/modes.py	Mon Jun 13 15:48:03 2011 -0400
+++ b/plugin/threesomelib/modes.py	Mon Jun 13 16:13:44 2011 -0400
@@ -1,5 +1,6 @@
 import vim
 from util import buffers, windows
+from settings import setting
 
 
 current_mode = None
@@ -7,7 +8,6 @@
 class Mode(object):
     def __init__(self):
         self._current_diff_mode = 0
-        self._current_layout = 0
         return super(Mode, self).__init__()
 
 
@@ -96,6 +96,7 @@
     """
 
     def __init__(self):
+        self._current_layout = int(setting('initial_layout_grid', 0))
         self._number_of_diff_modes = 2
         self._number_of_layouts = 3
 
@@ -221,6 +222,7 @@
 
 class LoupeMode(Mode):
     def __init__(self):
+        self._current_layout = int(setting('initial_layout_loupe', 0))
         self._number_of_diff_modes = 1
         self._number_of_layouts = 1
 
@@ -272,6 +274,7 @@
 
 class CompareMode(Mode):
     def __init__(self):
+        self._current_layout = int(setting('initial_layout_compare', 0))
         self._number_of_diff_modes = 2
         self._number_of_layouts = 2
 
@@ -421,6 +424,7 @@
 
 class PathMode(Mode):
     def __init__(self):
+        self._current_layout = int(setting('initial_layout_path', 0))
         self._number_of_diff_modes = 5
         self._number_of_layouts = 2
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugin/threesomelib/settings.py	Mon Jun 13 16:13:44 2011 -0400
@@ -0,0 +1,10 @@
+import vim
+
+
+def setting(name, default=None):
+    full_name = 'g:threesome_' + name
+
+    if not int(vim.eval('exists("%s")' % full_name)):
+        return default
+    else:
+        return vim.eval(full_name)