Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2022-06-25 15:00:06 +0300
committerSimon Tatham <anakin@pobox.com>2022-06-25 16:29:40 +0300
commit1a568e3535a19b75647a7b9e4ac2192b5e9be536 (patch)
treede436e7e31e09e9841c7c801d18c7f367fa7bd88 /unix
parente8a8c2535dc198b16569f405caa96f895fce6824 (diff)
New function dlg_editbox_select_range.
This manipulates the selection inside an edit box, to select a specific range of characters in the contained text. The idea is that you can use it as a means of error highlighting, if the user has entered something invalid in that edit box and you want to draw their attention to the specific location of the part you're unhappy with.
Diffstat (limited to 'unix')
-rw-r--r--unix/dialog.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/unix/dialog.c b/unix/dialog.c
index eda622f1..161f393d 100644
--- a/unix/dialog.c
+++ b/unix/dialog.c
@@ -357,6 +357,27 @@ char *dlg_editbox_get(dlgcontrol *ctrl, dlgparam *dp)
unreachable("bad control type in editbox_get");
}
+void dlg_editbox_select_range(dlgcontrol *ctrl, dlgparam *dp,
+ size_t start, size_t len)
+{
+ struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
+ assert(uc->ctrl->type == CTRL_EDITBOX);
+
+ GtkWidget *entry = NULL;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ if (uc->combo)
+ entry = gtk_bin_get_child(GTK_BIN(uc->combo));
+#endif
+
+ if (uc->entry)
+ entry = uc->entry;
+
+ assert(entry && "we should have a GtkEntry one way or another");
+
+ gtk_editable_select_region(GTK_EDITABLE(entry), start, start + len);
+}
+
#if !GTK_CHECK_VERSION(2,4,0)
static void container_remove_and_destroy(GtkWidget *w, gpointer data)
{