aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-01-25 16:23:17 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-01-25 16:23:17 -0500
commit7a2d26a6541038a4233412a572c3975e2ae59717 (patch)
treedb544d2dba1c28737029df6273b86c4daba81a0e
parenta874a6dd0ae87f565a053324fed12bbc9a6152ce (diff)
downloadtextadept-7a2d26a6541038a4233412a572c3975e2ae59717.tar.gz
textadept-7a2d26a6541038a4233412a572c3975e2ae59717.zip
The cursor in the Project Manager can be set through textadept.pm.cursor.
-rw-r--r--core/.pm.lua2
-rw-r--r--src/lua_interface.c17
2 files changed, 17 insertions, 2 deletions
diff --git a/core/.pm.lua b/core/.pm.lua
index b04f78ea..61ddecc0 100644
--- a/core/.pm.lua
+++ b/core/.pm.lua
@@ -13,6 +13,8 @@ module('textadept.pm')
-- @name textadept.pm
-- @field entry_text The text in the entry.
-- @field width The width of the project manager.
+-- @field cursor The cursor in the project manager (string representation of
+-- current GtkTreePath).
pm = {}
--- Focuses the project manager entry.
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 2e9c3f5f..180242ab 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -1267,6 +1267,13 @@ static int l_pm_mt_index(lua_State *lua) {
int pos =
gtk_paned_get_position(GTK_PANED(gtk_widget_get_parent(pm_container)));
lua_pushnumber(lua, pos);
+ } else if (streq(key, "cursor")) {
+ GtkTreePath *path = NULL;
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(pm_view), &path, NULL);
+ if (path) {
+ lua_pushstring(lua, gtk_tree_path_to_string(path));
+ gtk_tree_path_free(path);
+ } else lua_pushnil(lua);
} else lua_rawget(lua, 1);
return 1;
}
@@ -1278,8 +1285,14 @@ static int l_pm_mt_newindex(lua_State *lua) {
else if (streq(key, "width"))
gtk_paned_set_position(GTK_PANED(gtk_widget_get_parent(pm_container)),
luaL_checkinteger(lua, 3));
- else
- lua_rawset(lua, 1);
+ else if (streq(key, "cursor")) {
+ GtkTreePath *path = gtk_tree_path_new_from_string(lua_tostring(lua, 3));
+ if (path) {
+ GtkTreeViewColumn *col =
+ gtk_tree_view_get_column(GTK_TREE_VIEW(pm_view), 0);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(pm_view), path, col, FALSE);
+ } else luaL_error(lua, "Bad path given for textadept.pm.cursor.");
+ } else lua_rawset(lua, 1);
return 0;
}