mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
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.
This commit is contained in:
parent
e8a8c2535d
commit
1a568e3535
2
dialog.h
2
dialog.h
@ -573,6 +573,8 @@ void dlg_checkbox_set(dlgcontrol *ctrl, dlgparam *dp, bool checked);
|
||||
bool dlg_checkbox_get(dlgcontrol *ctrl, dlgparam *dp);
|
||||
void dlg_editbox_set(dlgcontrol *ctrl, dlgparam *dp, char const *text);
|
||||
char *dlg_editbox_get(dlgcontrol *ctrl, dlgparam *dp); /* result must be freed by caller */
|
||||
void dlg_editbox_select_range(dlgcontrol *ctrl, dlgparam *dp,
|
||||
size_t start, size_t len);
|
||||
/* The `listbox' functions can also apply to combo boxes. */
|
||||
void dlg_listbox_clear(dlgcontrol *ctrl, dlgparam *dp);
|
||||
void dlg_listbox_del(dlgcontrol *ctrl, dlgparam *dp, int index);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -2217,6 +2217,14 @@ char *dlg_editbox_get(dlgcontrol *ctrl, dlgparam *dp)
|
||||
return GetDlgItemText_alloc(dp->hwnd, c->base_id+1);
|
||||
}
|
||||
|
||||
void dlg_editbox_select_range(dlgcontrol *ctrl, dlgparam *dp,
|
||||
size_t start, size_t len)
|
||||
{
|
||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||
assert(c && c->ctrl->type == CTRL_EDITBOX);
|
||||
SendDlgItemMessage(dp->hwnd, c->base_id+1, EM_SETSEL, start, start+len);
|
||||
}
|
||||
|
||||
/* The `listbox' functions can also apply to combo boxes. */
|
||||
void dlg_listbox_clear(dlgcontrol *ctrl, dlgparam *dp)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user