summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth Parker <gareth@brainnwave.com>2019-07-05 10:44:25 +0100
committerGareth Parker <gareth@brainnwave.com>2019-07-05 10:44:25 +0100
commit8ba5dd6bde4ba004609cc3586dfa5121f934cd51 (patch)
tree6ec2f1b871a99593886c952949a3dcb0c2c204dc
parentc7ae718e2d8e8c2d5af7e0ae4b8931ceb40a1d9f (diff)
downloadvdebug-8ba5dd6bde4ba004609cc3586dfa5121f934cd51.zip
Another way to let people choose between layouts
-rw-r--r--plugin/vdebug.vim33
-rw-r--r--python3/vdebug/ui/vimui.py35
2 files changed, 56 insertions, 12 deletions
diff --git a/plugin/vdebug.vim b/plugin/vdebug.vim
index 084e640..2a7d88f 100644
--- a/plugin/vdebug.vim
+++ b/plugin/vdebug.vim
@@ -95,16 +95,31 @@ let g:vdebug_options_defaults = {
\ 'background_listener' : 1,
\ 'auto_start' : 1,
\ 'simplified_status': 1,
-\ 'window_commands' : {
-\ 'DebuggerWatch' : 'below new',
-\ 'DebuggerStack' : 'belowright new',
-\ 'DebuggerStatus' : 'vertical leftabove new'
+\ 'layouts' : {
+\ 'vertical': {
+\ 'window_commands' : {
+\ 'DebuggerWatch' : 'vertical belowright new',
+\ 'DebuggerStack' : 'aboveleft 12new',
+\ 'DebuggerStatus' : 'aboveleft 1new'
+\ },
+\ 'window_size' : {
+\ },
+\ 'window_arrangement' : ['DebuggerWatch', 'DebuggerStack', 'DebuggerStatus']
+\ },
+\ 'horizontal': {
+\ 'window_commands' : {
+\ 'DebuggerWatch' : 'below new',
+\ 'DebuggerStack' : 'belowright new',
+\ 'DebuggerStatus' : 'vertical leftabove new'
+\ },
+\ 'window_size' : {
+\ 'DebuggerWatch' : { 'height' : 15 },
+\ 'DebuggerStatus' : { 'height' : 1 }
+\ },
+\ 'window_arrangement' : ['DebuggerWatch', 'DebuggerStatus', 'DebuggerStack']
+\ }
\ },
-\ 'window_size' : {
-\ 'DebuggerWatch' : { 'height' : 15 },
-\ 'DebuggerStatus' : { 'height' : 1 },
-\ },
-\ 'window_arrangement' : ['DebuggerWatch', 'DebuggerStatus', 'DebuggerStack']
+\ 'default_layout': 'horizontaltest',
\}
" Different symbols for non unicode Vims
diff --git a/python3/vdebug/ui/vimui.py b/python3/vdebug/ui/vimui.py
index d543ad5..0eafb49 100644
--- a/python3/vdebug/ui/vimui.py
+++ b/python3/vdebug/ui/vimui.py
@@ -34,10 +34,14 @@ class WindowManager:
"DebuggerTrace": 'rightbelow 7new'
}
self._commands = self._default_commands.copy()
+ self._layout = None
def open_all(self):
self._refresh_commands()
- arrangement = opts.Options.get('window_arrangement', list)
+ arrangement = self._layout["window_arrangement"] \
+ if self._layout is not None and "window_arrangement" in self._layout else \
+ ('DebuggerWatch', 'DebuggerStack', 'DebuggerStatus')
+
for name in arrangement:
self.window(name).create(self._command(name))
@@ -85,9 +89,20 @@ class WindowManager:
raise WindowError("No debugger window named '%s' - check your "
"window options" % name)
+ def set_layout(self, layout):
+ self._layout = layout
+
def _refresh_commands(self):
self._commands = self._default_commands.copy()
- self._commands.update(opts.Options.get('window_commands', dict))
+
+ updated_commands = self._layout["window_commands"] \
+ if self._layout is not None and "window_commands" in self._layout else \
+ {
+ 'DebuggerWatch': 'vertical belowright new',
+ 'DebuggerStack': 'aboveleft 12 new',
+ 'DebuggerStatus': 'aboveleft 12 new'
+ }
+ self._commands.update(updated_commands)
class Ui(interface.Ui):
@@ -103,6 +118,14 @@ class Ui(interface.Ui):
self.tabnr = None
self._last_error = None
self.empty_buf_num = None
+ self.default_layout = {
+ 'window_commands': {
+ 'DebuggerWatch': 'vertical belowright new',
+ 'DebuggerStack': 'aboveleft 12new',
+ 'DebuggerStatus': 'aboveleft 1new',
+ },
+ 'window_arrangement': ['DebuggerWatch', 'DebuggerStack', 'DebuggerStatus']
+ }
def mark_window_as_closed(self, name):
self.windows.window(name).mark_as_closed()
@@ -123,6 +146,11 @@ class Ui(interface.Ui):
self.is_open = True
try:
+ layouts = opts.Options.get('layouts', dict)
+ default_layout = opts.Options.get('default_layout', str)
+
+ layout = layouts[default_layout] if default_layout in layouts else self.default_layout
+
existing_buffer = True
cur_buf_name = vim.current.buffer.name
if cur_buf_name is None:
@@ -138,11 +166,12 @@ class Ui(interface.Ui):
self.tabnr = vim.current.tabpage.number
+ self.windows.set_layout(layout)
self.windows.open_all()
statuswin = self.windows.status()
statuswin.set_status("loading")
- window_sizes = opts.Options.get('window_size', dict)
+ window_sizes = layout["window_size"] if "window_size" in layout else {}
for window_name, settings in window_sizes.items():
if 'height' in settings:
self.windows.window(window_name).set_height(settings['height'])