diff options
author | 2008-09-24 21:05:49 -0400 | |
---|---|---|
committer | 2008-09-24 21:05:49 -0400 | |
commit | 32503fed4cf3066b07384562f10b640026d634a8 (patch) | |
tree | f69a9df8364932e9db57327bbf29ed2ade5efbd4 | |
parent | 4554c2ca782ea2667570d81899142af8a642aa3b (diff) | |
download | textadept-32503fed4cf3066b07384562f10b640026d634a8.tar.gz textadept-32503fed4cf3066b07384562f10b640026d634a8.zip |
Added textadept.size property.
-rw-r--r-- | core/file_io.lua | 7 | ||||
-rw-r--r-- | src/lua_interface.c | 17 | ||||
-rw-r--r-- | src/textadept.c | 3 |
3 files changed, 23 insertions, 4 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index cc12fd28..6664d400 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -212,7 +212,10 @@ function load_session(filename, only_pm) current_view = tonumber(view_idx) or 1 end end - if line:match('^pm:') then + if line:match('^size:') then + local width, height = line:match('^size: (%d+) (%d+)$') + if width and height then textadept.size = { width, height } end + elseif line:match('^pm:') then local width, text = line:match('^pm: (%d+) (.+)$') textadept.pm.width = width or 0 textadept.pm.entry_text = text or '' @@ -286,6 +289,8 @@ function save_session(filename) end session = session..("current_view: %d\n"):format(current_view) -- Write out other things. + local size = textadept.size + session = session..("size: %d %d\n"):format( size[1], size[2] ) local pm = textadept.pm session = session..("pm: %d %s\n"):format(pm.width, pm.entry_text) -- Write the session. diff --git a/src/lua_interface.c b/src/lua_interface.c index 9cf49eea..dc5bfa0b 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -1099,6 +1099,12 @@ LF l_ta_mt_index(LS *lua) { gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); if (text) lua_pushstring(lua, text); g_free(text); + } else if (streq(key, "size")) { + lua_newtable(lua); + int width, height; + gtk_window_get_size(GTK_WINDOW(window), &width, &height); + lua_pushnumber(lua, width); lua_rawseti(lua, -2, 1); + lua_pushnumber(lua, height); lua_rawseti(lua, -2, 2); } else lua_rawget(lua, 1); return 1; } @@ -1124,6 +1130,16 @@ LF l_ta_mt_newindex(LS *lua) { gtk_menu_bar_append(GTK_MENU_BAR(menubar), menu_item); lua_pop(lua, 1); // value } set_menubar(menubar); + } else if (streq(key, "size")) { + const char *errmsg = "textadept.size must be a table ({ width, height })."; + if (!lua_istable(lua, 3) || lua_objlen(lua, 3) != 2) + luaL_error(lua, errmsg); + lua_rawgeti(lua, 3, 1); lua_rawgeti(lua, 3, 2); + int width = static_cast<int>(lua_tonumber(lua, -2)); + int height = static_cast<int>(lua_tonumber(lua, -1)); + lua_pop(lua, 2); // width, height + if (width > 0 && height > 0) + gtk_window_resize(GTK_WINDOW(window), width, height); } else lua_rawset(lua, 1); return 0; } @@ -1364,5 +1380,4 @@ LF l_cf_pm_activate(LS *) { g_signal_emit_by_name(G_OBJECT(pm_entry), "activate"); return 0; } LF l_cf_find_focus(LS *) { find_toggle_focus(); return 0; } - LF l_cf_ce_focus(LS *) { ce_toggle_focus(); return 0; } diff --git a/src/textadept.c b/src/textadept.c index dec065f1..eba730a1 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -467,8 +467,7 @@ static gbool cec_match_selected(GtkEntryCompletion*, GtkTreeModel *model, * Signal for a Scintilla notification. */ static void t_notification(GtkWidget*, gint, gpointer lParam, gpointer) { - SCNotification *n = reinterpret_cast<SCNotification*>(lParam); - l_handle_scnnotification(n); + l_handle_scnnotification(reinterpret_cast<SCNotification*>(lParam)); } /** |