diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2014-02-12 20:08:12 -0500 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2014-02-12 20:08:12 -0500 |
commit | 797674b8f29ddca2c8714387db226535d2d4c8ab (patch) | |
tree | c51e382f2bec4f7cbaed5b500fa3a84ea2cb77b5 | |
parent | e41406fbb3d02507964c89ef8bc1f7f42ae02f18 (diff) |
Added split views in the terminal version thanks to Chris Emerson.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | THANKS.md | 1 | ||||
-rw-r--r-- | doc/03_UserInterface.md | 6 | ||||
-rw-r--r-- | doc/04_WorkingWithFiles.md | 22 | ||||
-rw-r--r-- | doc/06_AdeptEditing.md | 12 | ||||
-rw-r--r-- | doc/index.html | 4 | ||||
-rw-r--r-- | modules/textadept/keys.lua | 67 | ||||
-rw-r--r-- | src/Makefile | 23 | ||||
-rw-r--r-- | src/textadept.c | 63 |
9 files changed, 125 insertions, 75 deletions
@@ -14,7 +14,7 @@ speed or succumbing to code bloat and featuritis. * Self-contained executable -- no installation necessary. * Entirely keyboard driven. -* Unlimited split views (GUI version). +* Unlimited split views. * Support for over 80 programming languages. * Powerful snippets and key commands. * Code autocompletion and API lookup. @@ -11,6 +11,7 @@ Textadept the amazing editor that it is today. * Bill Meahan
* Brian Schott
* Callum Wilson
+* Chris Emerson
* Gilles Grégoire
* Jay Gould
* Jeff Stone
diff --git a/doc/03_UserInterface.md b/doc/03_UserInterface.md index 6f232d37..19e28534 100644 --- a/doc/03_UserInterface.md +++ b/doc/03_UserInterface.md @@ -30,9 +30,9 @@ Textadept's [buffer browser][] is always available and far more powerful. ## Editor View -Most of your time spent with Textadept is in the editor view. The GUI version -features unlimited view splitting both vertically and horizontally. Lua also has -complete control over all views. +Most of your time spent with Textadept is in the editor view. Both the GUI +version and the terminal version feature unlimited vertical and horizontal view +splitting. Lua also has complete control over all views. ## Find & Replace Pane diff --git a/doc/04_WorkingWithFiles.md b/doc/04_WorkingWithFiles.md index 6f61d1da..9ea15e84 100644 --- a/doc/04_WorkingWithFiles.md +++ b/doc/04_WorkingWithFiles.md @@ -108,20 +108,22 @@ in [scripts][]. Textadept allows you to split the editor window an unlimited number of times both horizontally and vertically. `Ctrl+Alt+S` or `Ctrl+Alt+H` splits horizontally into top and bottom views and `Ctrl+Alt+V` splits vertically (`^S` -and `^V` respectively on Mac OSX | N/A in curses) into side-by-side views. -Clicking and dragging on the splitter bar with the mouse or pressing -`Ctrl+Alt++` and `Ctrl+Alt+-` (`^+` and `^-` | N/A) resizes the split. Textadept -supports viewing a single buffer in two or more views. +and `^V`, respectively on Mac OSX | `M-^V S` and `M-^V V` in curses) into +side-by-side views. Clicking and dragging on the splitter bar with the mouse or +pressing `Ctrl+Alt++` and `Ctrl+Alt+-` (`^+` and `^-` | `M-^V +` and `M-^V -`) +resizes the split. Textadept supports viewing a single buffer in two or more +views. -Pressing `Ctrl+Alt+N` (`^⌥⇥` on Mac OSX | N/A in curses) jumps to the next view -and `Ctrl+Alt+P` (`^⌥⇧⇥` | N/A) jumps the previous one. However, depending on -the split sequence, the order when cycling between views may not be linear. +Pressing `Ctrl+Alt+N` (`^⌥⇥` on Mac OSX | `M-^V N` in curses) jumps to the next +view and `Ctrl+Alt+P` (`^⌥⇧⇥` | `M-^V P`) jumps the previous one. However, +depending on the split sequence, the order when cycling between views may not be +linear. To unsplit a view, enter the view to keep open and press `Ctrl+Alt+W` (`^W` on -Mac OSX | N/A in curses). To unsplit all views, use `Ctrl+Alt+Shift+W` (`^⇧W` | -N/A). +Mac OSX | `M-^V W` in curses). To unsplit all views, use `Ctrl+Alt+Shift+W` +(`^⇧W` | `M-^V S-W`). -Textadept curses does not support split views. +Note: Textadept curses uses the `M-^V` key prefix for split views. ### Settings diff --git a/doc/06_AdeptEditing.md b/doc/06_AdeptEditing.md index d4857e2f..b5e66b88 100644 --- a/doc/06_AdeptEditing.md +++ b/doc/06_AdeptEditing.md @@ -127,7 +127,7 @@ XML tags. Pressing `Ctrl+Alt+U` or `Ctrl+Alt+Shift+U` (`^U` or `^⇧U` on Mac OSX | `M-^U` or `M-^L` in curses) converts selected text to upper case letters or lower case -letters respectively. +letters, respectively. #### Change Indent Level @@ -156,11 +156,11 @@ from a Lua pattern search, but always allows embedded Lua code enclosed in `%()`. Note the `Ctrl+G`, `Ctrl+Shift+G`, `Ctrl+Alt+R`, `Ctrl+Alt+Shift+R` key bindings -for find next, find previous, replace, and replace all (`⌘G`, `⌘⇧G`, `^R`, `^⇧R` -respectively on Mac OSX | `M-G`, `M-S-G`, `M-R`, `M-S-R` in curses) only work -after hiding the Find & Replace pane. For at least the English locale in the GUI -version, use the button mnemonics: `Alt+N`, `Alt+P`, `Alt+R`, and `Alt+A` (`⌘N`, -`⌘P`, `⌘R`, `⌘A` | N/A) after bringing up the pane. +for find next, find previous, replace, and replace all (`⌘G`, `⌘⇧G`, `^R`, and +`^⇧R`, respectively on Mac OSX | `M-G`, `M-S-G`, `M-R`, `M-S-R` in curses) only +work after hiding the Find & Replace pane. For at least the English locale in +the GUI version, use the button mnemonics: `Alt+N`, `Alt+P`, `Alt+R`, and +`Alt+A` (`⌘N`, `⌘P`, `⌘R`, `⌘A` | N/A) after bringing up the pane. In the curses version, `Tab` and `S-Tab` toggles between the find next, find previous, replace, and replace all buttons; `Up` and `Down` arrows switch diff --git a/doc/index.html b/doc/index.html index 18064afc..56b56c52 100644 --- a/doc/index.html +++ b/doc/index.html @@ -137,8 +137,8 @@ <div class="left-col"> <h3>Unlimited Split Views</h3> <p> - The graphical version of Textadept supports unlimited view splitting - both vertically and horizontally. + Both the graphical version and the terminal version of Textadept + support unlimited vertical and horizontal view splitting. </p> <p class="center"> <img src="images/splitviews.png" alt="Split Views" /> diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua index 997fb4ca..7a341977 100644 --- a/modules/textadept/keys.lua +++ b/modules/textadept/keys.lua @@ -118,24 +118,24 @@ local M = {} -- None |None |None |UTF-16 encoding -- Ctrl+Shift+L |⌘⇧L |M-S-L |Select lexer... -- F5 |F5 |^L<br/>F5 |Refresh syntax highlighting --- **View** | | | --- Ctrl+Alt+N |^⌥⇥ |N/A |Next view --- Ctrl+Alt+P |^⌥⇧⇥ |N/A |Previous view --- Ctrl+Alt+S<br/>Ctrl+Alt+H|^S |N/A |Split view horizontally --- Ctrl+Alt+V |^V |N/A |Split view vertically --- Ctrl+Alt+W |^W |N/A |Unsplit view --- Ctrl+Alt+Shift+W |^⇧W |N/A |Unsplit all views --- Ctrl+Alt++<br/>Ctrl+Alt+=|^+<br/>^=|N/A |Grow view --- Ctrl+Alt+- |^- |N/A |Shrink view --- Ctrl+* |⌘* |M-* |Toggle current fold --- Ctrl+Alt+Enter |^↩ |None |Toggle view EOL --- Ctrl+Alt+\\ |^\\ |None |Toggle wrap mode --- Ctrl+Alt+Shift+I |^⇧I |N/A |Toggle show indent guides --- Ctrl+Alt+Shift+S |^⇧S |None |Toggle view whitespace --- Ctrl+Alt+Shift+V |^⇧V |None |Toggle virtual space --- Ctrl+= |⌘= |N/A |Zoom in --- Ctrl+- |⌘- |N/A |Zoom out --- Ctrl+0 |⌘0 |N/A |Reset zoom +-- **View** | | | +-- Ctrl+Alt+N |^⌥⇥ |M-^V N |Next view +-- Ctrl+Alt+P |^⌥⇧⇥ |M-^V P |Previous view +-- Ctrl+Alt+S<br/>Ctrl+Alt+H|^S |M-^V S<br/>M-^V H|Split view horizontal +-- Ctrl+Alt+V |^V |M-^V V |Split view vertical +-- Ctrl+Alt+W |^W |M-^V W |Unsplit view +-- Ctrl+Alt+Shift+W |^⇧W |M-^V S-W |Unsplit all views +-- Ctrl+Alt++<br/>Ctrl+Alt+=|^+<br/>^=|M-^V +<br/>M-^V =|Grow view +-- Ctrl+Alt+- |^- |M-^V - |Shrink view +-- Ctrl+* |⌘* |M-* |Toggle current fold +-- Ctrl+Alt+Enter |^↩ |None |Toggle view EOL +-- Ctrl+Alt+\\ |^\\ |None |Toggle wrap mode +-- Ctrl+Alt+Shift+I |^⇧I |N/A |Toggle indent guides +-- Ctrl+Alt+Shift+S |^⇧S |None |Toggle view whitespace +-- Ctrl+Alt+Shift+V |^⇧V |None |Toggle virtual space +-- Ctrl+= |⌘= |N/A |Zoom in +-- Ctrl+- |⌘- |N/A |Zoom out +-- Ctrl+0 |⌘0 |N/A |Reset zoom -- **Help**| | | -- F1 |F1 |None|Open manual -- Shift+F1|⇧F1 |None|Open LuaDoc @@ -188,7 +188,7 @@ local M = {} -- N/A |N/A |^^ |Mark text at the caret position -- N/A |N/A |^] |Swap caret and mark anchor -- **Other** | | | --- Ctrl+Shift+U, xxxx, Enter|None|None|Input Unicode character U-xxxx. +-- Ctrl+Shift+U *xxxx* Enter|None|None|Input Unicode character U-*xxxx*. -- **Entry Fields**| | | -- Left |⇠<br/>^B |^B<br/>Left |Cursor left -- Right |⇢<br/>^F |^F<br/>Right|Cursor right @@ -267,8 +267,8 @@ M.utils = { events.emit(events.UPDATE_UI) -- for updating statusbar end, unsplit_all = function() while view:unsplit() do end end, - grow = function() if view.size then view.size = view.size + 10 end end, - shrink = function() if view.size then view.size = view.size - 10 end end, + grow = function(i) if view.size then view.size = view.size + i end end, + shrink = function(i) if view.size then view.size = view.size - i end end, toggle_current_fold = function() buffer:toggle_fold(buffer:line_from_position(buffer.current_pos)) end, @@ -348,7 +348,7 @@ for _, f in ipairs(menu_buffer_functions) do buffer[f] = buffer[f] end -- -- Unassigned keys (~ denotes keys reserved by the operating system): -- c: g~~ ~ --- cm: bcd g~~ k ~ pq t v xyz +-- cm: bcd g~~ k ~ pq t xyz -- m: e J qQ sS u vVw yYzZ_ + -- Note: m[befhstv] may be used by Linux/BSD GUI terminals for menu access. -- @@ -527,17 +527,28 @@ keys.f5 = {buffer.colourise, buffer, 0, -1} if CURSES then keys.cl = keys.f5 end -- View. +local view_next, view_prev = {ui.goto_view, 1, true}, {ui.goto_view, -1, true} +local view_splith, view_splitv = {view.split, view}, {view.split, view, true} +local view_unsplit = {view.unsplit, view} if not CURSES then - keys[not OSX and 'can' or 'ca\t'] = {ui.goto_view, 1, true} - keys[not OSX and 'cap' or 'cas\t'] = {ui.goto_view, -1, true} - keys[not OSX and 'cas' or 'cs'] = {view.split, view} - if not OSX then keys.cah = keys.cas end - keys[not OSX and 'cav' or 'cv'] = {view.split, view, true} - keys[not OSX and 'caw' or 'cw'] = {view.unsplit, view} + keys[not OSX and 'can' or 'ca\t'] = view_next + keys[not OSX and 'cap' or 'cas\t'] = view_prev + keys[not OSX and 'cas' or 'cs'] = view_splith + if not OSX then keys.cah = view_splith end + keys[not OSX and 'cav' or 'cv'] = view_splitv + keys[not OSX and 'caw' or 'cw'] = view_unsplit keys[not OSX and 'caW' or 'cW'] = utils.unsplit_all keys[not OSX and 'ca+' or 'c+'] = {utils.grow, 10} keys[not OSX and 'ca=' or 'c='] = {utils.grow, 10} keys[not OSX and 'ca-' or 'c-'] = {utils.shrink, 10} +else + keys.cmv = { + n = view_next, p = view_prev, + s = view_splith, v = view_splitv, + w = view_unsplit, W = utils.unsplit_all, + ['+'] = {utils.grow, 1}, ['='] = {utils.grow, 1}, ['-'] = {utils.shrink, 1} + } + if not OSX then keys.cmv.h = view_splith end end keys[not OSX and not CURSES and 'c*' or 'm*'] = utils.toggle_current_fold if not CURSES then diff --git a/src/Makefile b/src/Makefile index 12dfc95c..993b1f00 100644 --- a/src/Makefile +++ b/src/Makefile @@ -186,6 +186,7 @@ ifeq (win, $(findstring win, $(MAKECMDGOALS))) luajit_lib_objs += wutilsjit.o winapijit.o endif termkey_objs = termkey.o driver-ti.o driver-csi.o +windowman_objs = windowman.o cdk_objs = binding.o buttonbox.o button.o cdk.o cdk_display.o cdk_objs.o \ cdk_params.o cdkscreen.o debug.o draw.o entry.o fselect.o \ itemlist.o label.o mentry.o menu.o popup_label.o position.o \ @@ -205,7 +206,7 @@ osx-curses: textadept-curses textadeptjit-curses # Dependencies. base_deps = scintilla scintilla/term scintillua lua lualibs luajit gtdialog \ - cdk $(bombay) + windowman cdk $(bombay) deps: $(base_deps) termkey win32-deps: $(base_deps) win32gtk win32curses osx-deps: $(base_deps) gtkosx termkey @@ -240,10 +241,10 @@ textadeptjit.o: textadept.c $< -o $@ textadept-curses.o: textadept.c $(CROSS)$(CC) -c $(CFLAGS) $(ta_flags) -Ilua/src -Iscintilla/term -Itermkey \ - -Icdk $(CURSES_CFLAGS) $< -o $@ + -Iwindowman -Icdk $(CURSES_CFLAGS) $< -o $@ textadeptjit-curses.o: textadept.c $(CROSS)$(CC) -c $(CFLAGS) $(ta_flags) -DLUAJIT -Iluajit/src \ - -Iscintilla/term -Itermkey -Icdk $(CURSES_CFLAGS) $< -o $@ + -Iscintilla/term -Itermkey -Iwindowman -Icdk $(CURSES_CFLAGS) $< -o $@ $(lua_objs): %.o: lua/src/%.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) -Ilua/src $< -o $@ $(lua_lib_objs): %.o: lua/src/lib/%.c @@ -264,6 +265,8 @@ gtdialog.o: gtdialog/gtdialog.c gtdialog-curses.o: gtdialog/gtdialog.c $(CROSS)$(CC) -c $(CFLAGS) -DCURSES -DNOHELP -DLIBRARY -Icdk \ $(CURSES_CFLAGS) $< -o $@ +$(windowman_objs): %.o: windowman/%.c + $(CROSS)$(CC) -c $(CFLAGS) -Iwindowman $(CURSES_CFLAGS) $< -o $@ $(cdk_objs): %.o: cdk/%.c $(CROSS)$(CC) -c $(CFLAGS) -D_GNU_SOURCE -Itermkey -Icdk $(CURSES_CFLAGS) $< \ -o $@ @@ -281,12 +284,13 @@ textadeptjit: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \ $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadept-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o LexLPeg-curses.o \ textadept-curses.o $(lua_objs) $(lua_lib_objs) \ - gtdialog-curses.o $(termkey_objs) $(cdk_objs) + gtdialog-curses.o $(termkey_objs) $(windowman_objs) \ + $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadeptjit-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPegjit-curses.o textadeptjit-curses.o \ $(luajit_lib_objs) $(libluajit) gtdialog-curses.o \ - $(termkey_objs) $(cdk_objs) + $(termkey_objs) $(windowman_objs) $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadept.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \ LexLPeg.o textadept.o textadept_rc.o $(lua_objs) \ @@ -298,12 +302,13 @@ textadeptjit.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) \ $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadept-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPeg-curses.o textadept-curses.o textadept_rc.o \ - $(lua_objs) $(lua_lib_objs) gtdialog-curses.o $(cdk_objs) + $(lua_objs) $(lua_lib_objs) gtdialog-curses.o \ + $(windowman_objs) $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadeptjit-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPegjit-curses.o textadeptjit-curses.o \ textadept_rc.o $(luajit_lib_objs) $(lua_dll) \ - gtdialog-curses.o $(cdk_objs) + gtdialog-curses.o $(windowman_objs) $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) # Install/uninstall. @@ -430,6 +435,7 @@ lwinapi_zip = 23dd43141d04d010a9986cca9e5ecb9e598a2899.zip luajit_tgz = LuaJIT-2.0.2.tar.gz libluajit_tgz = libluajit_2.0.2.x86_64.tgz gtdialog_zip = gtdialog.zip +windowman_zip = windowman.zip cdk_tgz = cdk.tar.gz termkey_tgz = libtermkey-0.16.tar.gz win32gtk_zip = gtk+-bundle_2.24.10-20120208_win32.zip @@ -478,6 +484,9 @@ $(libluajit_tgz): ; wget "http://foicica.com/textadept/download/$@" libluajit64: | $(libluajit_tgz) ; tar xzf $| $(gtdialog_zip): ; wget "http://foicica.com/hg/gtdialog/archive/tip.zip" -O $@ gtdialog: | $(gtdialog_zip) ; mkdir $@ && unzip -d $@ $| && mv $@/*/* $@ +$(windowman_zip): + wget "https://bitbucket.org/jugglerchris/curses-windowman/get/tip.zip" -O $@ +windowman: | $(windowman_zip) ; mkdir $@ && unzip -d $@ $| && mv $@/*/* $@ $(cdk_tgz): ; wget "http://invisible-island.net/datafiles/release/$@" cdk: cdk.patch | $(cdk_tgz) mkdir $@ && tar xzf $| -C $@ && mv $@/*/* $@ diff --git a/src/textadept.c b/src/textadept.c index aaaeeeaa..9053d0d3 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -46,6 +46,7 @@ #include "ScintillaWidget.h" #elif CURSES #include "ScintillaTerm.h" +#include "windowman.h" #include "cdk_int.h" #if !_WIN32 #include "termkey.h" @@ -147,6 +148,7 @@ static GtkListStore *cc_store; static GtkEntryCompletion *command_entry_completion; #elif CURSES // curses window. +static struct WindowManager *wm; #if !_WIN32 static struct termios term; TermKey *ta_tk; // global for CDK use @@ -155,6 +157,9 @@ TermKey *ta_tk; // global for CDK use #define focus_view(view) \ (focused_view ? SS(focused_view, SCI_SETFOCUS, 0, 0) : 0, \ SS(view, SCI_SETFOCUS, 1, 0)) +/** Callback for refreshing a single Scintilla view. */ +static void r_cb(void *view, void*_) {scintilla_refresh((Scintilla *)view);} +#define refresh_all() (wman_walk(wm, r_cb, NULL), wman_refresh(wm), refresh()) #define flushch() (timeout(0), getch(), timeout(-1)) // curses find & replace pane. static CDKSCREEN *findbox; @@ -458,7 +463,7 @@ static int lfind_focus(lua_State *L) { fcopy(&repl_text, getCDKEntryValue(replace_entry)); if (focused_entry->exitType == vNORMAL) { f_clicked(getCDKButtonboxCurrentButton(buttonbox), NULL); - scintilla_refresh(focused_view); + refresh_all(); } find_entry->exitType = replace_entry->exitType = vNEVER_ACTIVATED; activateCDKEntry(focused_entry, NULL); @@ -563,7 +568,7 @@ static int c_keypress(EObjectType _, void *object, void *data, chtype key) { if (key == 27) key = SCK_ESCAPE; int halt = lL_event(lua, "command_entry_keypress", LUA_TNUMBER, key, LUA_TBOOLEAN, FALSE, LUA_TBOOLEAN, ctrl, -1); - scintilla_refresh(focused_view), drawCDKEntry((CDKENTRY *)object, FALSE); + refresh_all(), drawCDKEntry((CDKENTRY *)object, FALSE); return !halt || key == SCK_ESCAPE; } #endif @@ -738,6 +743,16 @@ static void l_pushsplittable(lua_State *L, GtkWidget *w) { lua_pushinteger(L, size), lua_setfield(L, -2, "size"); } else l_pushview(L, w); } +#elif CURSES +static void l_pushsplittable(lua_State *L, struct WindowManager *wm) { + if (wm->dir != SPLIT_LEAF) { + lua_newtable(L); + l_pushsplittable(L, wm->first), lua_rawseti(L, -2, 1); + l_pushsplittable(L, wm->second), lua_rawseti(L, -2, 2); + lua_pushboolean(L, wm->dir == SPLIT_VER), lua_setfield(L, -2, "vertical"); + lua_pushinteger(L, wm->splitpos), lua_setfield(L, -2, "size"); + } else l_pushview(L, wm->view); +} #endif /** `ui.get_split_table()` Lua function. */ @@ -747,7 +762,7 @@ static int lui_get_split_table(lua_State *L) { while (GTK_IS_PANED(gtk_widget_get_parent(w))) w = gtk_widget_get_parent(w); l_pushsplittable(L, w); #elif CURSES - l_pushview(L, focused_view); // TODO: push split table + l_pushsplittable(L, wm); #endif return 1; } @@ -1730,6 +1745,13 @@ static void remove_views_from_pane(GtkWidget *pane) { GTK_IS_PANED(child1) ? remove_views_from_pane(child1) : delete_view(child1); GTK_IS_PANED(child2) ? remove_views_from_pane(child2) : delete_view(child2); } +#elif CURSES +/** + * Signal that the curses window manager removed a view. + * @param view The view removed. + * @see delete_view + */ +static void view_removed(void *view, void*_) {delete_view((Scintilla *)view);} #endif /** @@ -1759,7 +1781,8 @@ static int unsplit_view(Scintilla *view) { gtk_widget_grab_focus(GTK_WIDGET(view)); g_object_unref(view), g_object_unref(other); #elif CURSES - return FALSE; + if (wm->dir == SPLIT_LEAF) return FALSE; + wman_unsplit_view(wm, view, view_removed), scintilla_refresh(view); #endif return TRUE; } @@ -1977,12 +2000,12 @@ static int lview_goto_buffer(lua_State *L) { * horozontally. */ static void split_view(Scintilla *view, int vertical) { -#if GTK sptr_t curdoc = SS(view, SCI_GETDOCPOINTER, 0, 0); int first_line = SS(view, SCI_GETFIRSTVISIBLELINE, 0, 0); int current_pos = SS(view, SCI_GETCURRENTPOS, 0, 0); int anchor = SS(view, SCI_GETANCHOR, 0, 0); +#if GTK GtkAllocation allocation; gtk_widget_get_allocation(view, &allocation); int middle = (vertical ? allocation.width : allocation.height) / 2; @@ -1998,15 +2021,16 @@ static void split_view(Scintilla *view, int vertical) { gtk_paned_set_position(GTK_PANED(pane), middle); gtk_widget_show_all(pane); g_object_unref(view); - focus_view(view2); while (gtk_events_pending()) gtk_main_iteration(); // ensure view2 is painted +#elif CURSES + Scintilla *view2 = new_view(curdoc); + wman_split_view(wm, vertical, view, view2, scintilla_get_window(view2)); +#endif + focus_view(view2); SS(view2, SCI_SETSEL, anchor, current_pos); int new_first_line = SS(view2, SCI_GETFIRSTVISIBLELINE, 0, 0); SS(view2, SCI_LINESCROLL, first_line - new_first_line, 0); -//#elif CURSES - // TODO: split. -#endif } /** `view.split()` Lua function. */ @@ -2034,7 +2058,8 @@ static int lview__index(lua_State *L) { lua_pushinteger(L, pos); } else lua_pushnil(L); #elif CURSES - lua_pushnil(L); // TODO: push size + struct WindowManager *parent = wman_parent(wm, wman_view_owner(wm, view)); + parent ? lua_pushinteger(L, parent->splitpos) : lua_pushnil(L); #endif } else lua_rawget(L, 1); return 1; @@ -2051,8 +2076,10 @@ static int lview__newindex(lua_State *L) { #if GTK GtkWidget *pane = gtk_widget_get_parent(lL_checkview(L, 1)); if (GTK_IS_PANED(pane)) gtk_paned_set_position(GTK_PANED(pane), size); -//#elif CURSES - // TODO: set size. +#elif CURSES + Scintilla *view = lL_checkview(L, 1); + struct WindowManager *split = wman_parent(wm, wman_view_owner(wm, view)); + if (split) wman_move_split(split, size); #endif } else lua_rawset(L, 1); return 0; @@ -2316,8 +2343,8 @@ static void new_window() { dummy_view = scintilla_new(); #elif CURSES Scintilla *view = new_view(0); - wresize(scintilla_get_window(view), LINES - 2, COLS); - mvwin(scintilla_get_window(view), 1, 0); + wm = wman_create(view, scintilla_get_window(view)); + wman_resize(wm, LINES - 2, COLS, 1, 0); dummy_view = scintilla_new(NULL); #endif } @@ -2328,9 +2355,9 @@ static void resize(int signal) { struct winsize win; ioctl(0, TIOCGWINSZ, &win); resizeterm(win.ws_row, win.ws_col); - wresize(scintilla_get_window(focused_view), LINES - 2, COLS); + wman_resize(wm, LINES - 2, COLS, 1, 0); lL_event(lua, "update_ui", -1); - scintilla_refresh(focused_view); + refresh_all(); } #endif @@ -2426,7 +2453,7 @@ int main(int argc, char **argv) { gtk_main(); #endif #elif CURSES - scintilla_refresh(focused_view); + refresh_all(); #if !_WIN32 stderr = freopen("/dev/null", "w", stderr); // redirect stderr @@ -2504,7 +2531,7 @@ int main(int argc, char **argv) { } break; } else quit = FALSE; - scintilla_refresh(focused_view); + refresh_all(); } endwin(); #if !_WIN32 |