Permalink
Browse files

Add boolsetting() and clean up a bit.

  • Loading branch information...
1 parent a52ef7a commit 7dac7b10016415b15621bc11a34fcd8bae989e33 @sjl committed Jun 13, 2011
Showing with 11 additions and 5 deletions.
  1. +5 −5 plugin/threesomelib/modes.py
  2. +6 −0 plugin/threesomelib/settings.py
View
10 plugin/threesomelib/modes.py
@@ -1,6 +1,6 @@
import vim
from util import buffers, windows
-from settings import setting
+from settings import boolsetting, setting
from util.io import error
@@ -130,7 +130,7 @@ class GridMode(Mode):
def __init__(self):
self._current_layout = int(setting('initial_layout_grid', 0))
self._current_diff_mode = int(setting('initial_diff_grid', 0))
- self._current_scrollbind = int(setting('initial_scrollbind_grid', 0)) and True or False
+ self._current_scrollbind = boolsetting('initial_scrollbind_grid')
self._number_of_diff_modes = 2
self._number_of_layouts = 3
@@ -259,7 +259,7 @@ class LoupeMode(Mode):
def __init__(self):
self._current_layout = int(setting('initial_layout_loupe', 0))
self._current_diff_mode = int(setting('initial_diff_loupe', 0))
- self._current_scrollbind = int(setting('initial_scrollbind_loupe', 0)) and True or False
+ self._current_scrollbind = boolsetting('initial_scrollbind_loupe')
self._number_of_diff_modes = 1
self._number_of_layouts = 1
@@ -314,7 +314,7 @@ class CompareMode(Mode):
def __init__(self):
self._current_layout = int(setting('initial_layout_compare', 0))
self._current_diff_mode = int(setting('initial_diff_compare', 0))
- self._current_scrollbind = int(setting('initial_scrollbind_compare', 0)) and True or False
+ self._current_scrollbind = boolsetting('initial_scrollbind_compare')
self._number_of_diff_modes = 2
self._number_of_layouts = 2
@@ -467,7 +467,7 @@ class PathMode(Mode):
def __init__(self):
self._current_layout = int(setting('initial_layout_path', 0))
self._current_diff_mode = int(setting('initial_diff_path', 0))
- self._current_scrollbind = int(setting('initial_scrollbind_path', 0)) and True or False
+ self._current_scrollbind = boolsetting('initial_scrollbind_path')
self._number_of_diff_modes = 5
self._number_of_layouts = 2
View
6 plugin/threesomelib/settings.py
@@ -8,3 +8,9 @@ def setting(name, default=None):
return default
else:
return vim.eval(full_name)
+
+def boolsetting(name):
+ if int(setting(name, 0)):
+ return True
+ else:
+ False

0 comments on commit 7dac7b1

Please sign in to comment.