diff options
-rw-r--r-- | core/gui.lua | 2 | ||||
-rw-r--r-- | doc/14_Appendix.md | 2 | ||||
-rw-r--r-- | modules/textadept/session.lua | 9 | ||||
-rw-r--r-- | src/textadept.c | 16 |
4 files changed, 23 insertions, 6 deletions
diff --git a/core/gui.lua b/core/gui.lua index b8b2071e..feb61734 100644 --- a/core/gui.lua +++ b/core/gui.lua @@ -17,6 +17,8 @@ local gui = gui -- The text displayed by the statusbar. -- @field docstatusbar_text (string, Write-only) -- The text displayed by the buffer statusbar. +-- @field maximized (bool) +-- Whether or not the Textadept window is maximized. module('gui')]] local theme = package.searchpath(not CURSES and 'light' or 'term', diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md index f92f4f35..f128c667 100644 --- a/doc/14_Appendix.md +++ b/doc/14_Appendix.md @@ -178,6 +178,7 @@ open |Changed |\_G.[io.snapopen()][]<sup>†</sup> **events** | | handlers |Removed |N/A **gui** | | +N/A |New |[maximized][] find.goto\_file\_in\_list() |Renamed |find.[goto\_file\_found()][] select\_theme |Removed |N/A **io** | | @@ -199,6 +200,7 @@ try\_encodings |Renamed |[encodings][] [select\_enclosed()]: api/_M.textadept.editing.html#select_enclosed [ERROR\_COLOR]: api/_M.textadept.run.html#ERROR_COLOR [io.snapopen()]: api/io.html#snapopen +[maximized]: api/gui.html#maximized [goto\_file\_found()]: api/gui.find.html#goto_file_found [encodings]: api/io.html#encodings diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index a7cd6dae..d9783512 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -89,8 +89,9 @@ function M.load(filename) elseif line:find('^current_view:') then current_view = tonumber(line:match('^current_view: (%d+)')) or 1 elseif line:find('^size:') then - local width, height = line:match('^size: (%d+) (%d+)$') - if width and height then gui.size = {width, height} end + local maximized, width, height = line:match('^size: (%l*) ?(%d+) (%d+)$') + maximized = maximized == 'true' + if maximized then gui.maximized = true else gui.size = {width, height} end elseif line:find('^recent:') then local filename = line:match('^recent: (.+)$') local recent, exists = io.recent_files, false @@ -179,8 +180,8 @@ function M.save(filename) -- Write out the current focused view. session[#session + 1] = ("current_view: %d"):format(_VIEWS[view]) -- Write out other things. - local size = gui.size - session[#session + 1] = ("size: %d %d"):format(size[1], size[2]) + local maximized, size = tostring(gui.maximized), gui.size + session[#session + 1] = ("size: %s %d %d"):format(maximized, size[1], size[2]) for i = 1, #io.recent_files do if i > M.MAX_RECENT_FILES then break end session[#session + 1] = ("recent: %s"):format(io.recent_files[i]) diff --git a/src/textadept.c b/src/textadept.c index ede35e19..0e028291 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -919,7 +919,14 @@ static int lgui__index(lua_State *L) { lua_pushlstring(L, text, scintilla_get_clipboard(focused_view, NULL)); free(text); #endif - } else if (strcmp(key, "size") == 0) { + } else if (strcmp(key, "maximized") == 0) +#if GTK + lua_pushboolean(L, gdk_window_get_state(window->window) & + GDK_WINDOW_STATE_MAXIMIZED); +#elif CURSES + lua_pushboolean(L, FALSE); +#endif + else if (strcmp(key, "size") == 0) { #if GTK int width, height; gtk_window_get_size(GTK_WINDOW(window), &width, &height); @@ -982,7 +989,12 @@ static int lgui__newindex(lua_State *L) { gtk_widget_hide(new_menubar); #endif #endif - } else if (strcmp(key, "size") == 0) { + } else if (strcmp(key, "maximized") == 0) +#if GTK + lua_toboolean(L, 3) ? gtk_window_maximize(GTK_WINDOW(window)) + : gtk_window_unmaximize(GTK_WINDOW(window)); +#endif + else if (strcmp(key, "size") == 0) { #if GTK luaL_argcheck(L, lua_istable(L, 3) && lua_rawlen(L, 3) == 2, 3, "{ width, height } table expected"); |