Handle mouse clicks on dictionary names
This commit is contained in:
parent
1f60d096ea
commit
b3458d84a0
35
src/sdtui.c
35
src/sdtui.c
|
@ -52,6 +52,7 @@
|
||||||
#define CTRL_KEY(x) ((x) - 'A' + 1)
|
#define CTRL_KEY(x) ((x) - 'A' + 1)
|
||||||
|
|
||||||
#define TOP_BAR_CUTOFF 2 ///< How many lines are reserved on top
|
#define TOP_BAR_CUTOFF 2 ///< How many lines are reserved on top
|
||||||
|
#define APP_TITLE PROJECT_NAME " " ///< Left top corner
|
||||||
|
|
||||||
// --- Utilities ---------------------------------------------------------------
|
// --- Utilities ---------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -873,7 +874,7 @@ app_redraw_top (Application *self)
|
||||||
{
|
{
|
||||||
attrset (APP_ATTR (HEADER));
|
attrset (APP_ATTR (HEADER));
|
||||||
mvwhline (stdscr, 0, 0, APP_ATTR (HEADER), COLS);
|
mvwhline (stdscr, 0, 0, APP_ATTR (HEADER), COLS);
|
||||||
gsize indent = app_add_utf8_string (self, PROJECT_NAME " ", A_BOLD, -1);
|
gsize indent = app_add_utf8_string (self, APP_TITLE, A_BOLD, -1);
|
||||||
|
|
||||||
attrset (0);
|
attrset (0);
|
||||||
for (guint i = 0; i < self->dictionaries->len; i++)
|
for (guint i = 0; i < self->dictionaries->len; i++)
|
||||||
|
@ -1280,14 +1281,6 @@ app_goto_dictionary (Application *self, guint n)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAVE_CURSOR \
|
|
||||||
int last_x, last_y; \
|
|
||||||
getyx (stdscr, last_y, last_x);
|
|
||||||
|
|
||||||
#define RESTORE_CURSOR \
|
|
||||||
move (last_y, last_x); \
|
|
||||||
refresh ();
|
|
||||||
|
|
||||||
/// The terminal has been resized, make appropriate changes.
|
/// The terminal has been resized, make appropriate changes.
|
||||||
static gboolean
|
static gboolean
|
||||||
app_process_resize (Application *self)
|
app_process_resize (Application *self)
|
||||||
|
@ -1345,6 +1338,14 @@ enum user_action
|
||||||
USER_ACTION_COUNT
|
USER_ACTION_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SAVE_CURSOR \
|
||||||
|
int last_x, last_y; \
|
||||||
|
getyx (stdscr, last_y, last_x);
|
||||||
|
|
||||||
|
#define RESTORE_CURSOR \
|
||||||
|
move (last_y, last_x); \
|
||||||
|
refresh ();
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -1668,7 +1669,21 @@ app_process_left_mouse_click (Application *self, int line, int column)
|
||||||
{
|
{
|
||||||
SAVE_CURSOR
|
SAVE_CURSOR
|
||||||
if (line == 0)
|
if (line == 0)
|
||||||
; // At the moment there's nothing useful for us to do
|
{
|
||||||
|
int indent = strlen (APP_TITLE);
|
||||||
|
if (column < indent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dictionary *dicts = (Dictionary *) self->dictionaries->data;
|
||||||
|
for (guint i = 0; i < self->dictionaries->len; i++)
|
||||||
|
{
|
||||||
|
if (column < (indent += dicts[i].name_width))
|
||||||
|
{
|
||||||
|
app_goto_dictionary (self, i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (line == 1)
|
else if (line == 1)
|
||||||
{
|
{
|
||||||
// FIXME: this is only an approximation
|
// FIXME: this is only an approximation
|
||||||
|
|
Loading…
Reference in New Issue