mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 20:16:21 +00:00
Allow previous autocompletion with shift tab
This commit is contained in:
@@ -505,7 +505,7 @@ cons_show_wins(gboolean unread)
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_room_invites(GSList *invites)
|
||||
cons_show_room_invites(GList *invites)
|
||||
{
|
||||
cons_show("");
|
||||
if (invites == NULL) {
|
||||
@@ -514,7 +514,7 @@ cons_show_room_invites(GSList *invites)
|
||||
cons_show("Chat room invites, use /join or /decline commands:");
|
||||
while (invites) {
|
||||
cons_show(" %s", invites->data);
|
||||
invites = g_slist_next(invites);
|
||||
invites = g_list_next(invites);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,17 +608,17 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
|
||||
void
|
||||
cons_show_received_subs(void)
|
||||
{
|
||||
GSList *received = presence_get_subscription_requests();
|
||||
GList *received = presence_get_subscription_requests();
|
||||
if (received == NULL) {
|
||||
cons_show("No outstanding subscription requests.");
|
||||
} else {
|
||||
cons_show("Outstanding subscription requests from:",
|
||||
g_slist_length(received));
|
||||
g_list_length(received));
|
||||
while (received) {
|
||||
cons_show(" %s", received->data);
|
||||
received = g_slist_next(received);
|
||||
received = g_list_next(received);
|
||||
}
|
||||
g_slist_free_full(received, g_free);
|
||||
g_list_free_full(received, g_free);
|
||||
}
|
||||
|
||||
cons_alert();
|
||||
|
||||
@@ -96,6 +96,7 @@ static void _inp_rl_addfuncs(void);
|
||||
static int _inp_rl_getc(FILE *stream);
|
||||
static void _inp_rl_linehandler(char *line);
|
||||
static int _inp_rl_tab_handler(int count, int key);
|
||||
static int _inp_rl_shift_tab_handler(int count, int key);
|
||||
static int _inp_rl_win_clear_handler(int count, int key);
|
||||
static int _inp_rl_win_1_handler(int count, int key);
|
||||
static int _inp_rl_win_2_handler(int count, int key);
|
||||
@@ -421,6 +422,7 @@ _inp_rl_startup_hook(void)
|
||||
rl_bind_keyseq("\\eOs", _inp_rl_win_pagedown_handler);
|
||||
|
||||
rl_bind_key('\t', _inp_rl_tab_handler);
|
||||
rl_bind_keyseq("\\e[Z", _inp_rl_shift_tab_handler);
|
||||
|
||||
// unbind unwanted mappings
|
||||
rl_bind_keyseq("\\e=", NULL);
|
||||
@@ -449,10 +451,27 @@ _inp_rl_linehandler(char *line)
|
||||
inp_line = line;
|
||||
}
|
||||
|
||||
static gboolean shift_tab = FALSE;
|
||||
|
||||
static int
|
||||
_inp_rl_getc(FILE *stream)
|
||||
{
|
||||
int ch = rl_getc(stream);
|
||||
|
||||
// 27, 91, 90 = Shift tab
|
||||
if (ch == 27) {
|
||||
shift_tab = TRUE;
|
||||
return ch;
|
||||
}
|
||||
if (shift_tab && ch == 91) {
|
||||
return ch;
|
||||
}
|
||||
if (shift_tab && ch == 90) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
shift_tab = FALSE;
|
||||
|
||||
if (_inp_printable(ch)) {
|
||||
ProfWin *window = wins_get_current();
|
||||
cmd_ac_reset(window);
|
||||
@@ -477,7 +496,7 @@ _inp_rl_tab_handler(int count, int key)
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) {
|
||||
char *result = muc_autocomplete(current, rl_line_buffer);
|
||||
char *result = muc_autocomplete(current, rl_line_buffer, FALSE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
@@ -485,7 +504,35 @@ _inp_rl_tab_handler(int count, int key)
|
||||
}
|
||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer);
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer, FALSE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
free(result);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_shift_tab_handler(int count, int key)
|
||||
{
|
||||
if (rl_point != rl_end || !rl_line_buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) {
|
||||
char *result = muc_autocomplete(current, rl_line_buffer, TRUE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
free(result);
|
||||
}
|
||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer, TRUE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
|
||||
@@ -138,13 +138,13 @@ rosterwin_roster(void)
|
||||
_rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb");
|
||||
_rosterwin_contacts_by_presence(layout, "offline", "Offline");
|
||||
} else if (g_strcmp0(by, "group") == 0) {
|
||||
GSList *groups = roster_get_groups();
|
||||
GSList *curr_group = groups;
|
||||
GList *groups = roster_get_groups();
|
||||
GList *curr_group = groups;
|
||||
while (curr_group) {
|
||||
_rosterwin_contacts_by_group(layout, curr_group->data);
|
||||
curr_group = g_slist_next(curr_group);
|
||||
curr_group = g_list_next(curr_group);
|
||||
}
|
||||
g_slist_free_full(groups, free);
|
||||
g_list_free_full(groups, free);
|
||||
_rosterwin_contacts_by_group(layout, NULL);
|
||||
} else {
|
||||
_rosterwin_contacts_all(layout);
|
||||
|
||||
@@ -278,7 +278,7 @@ void cons_show_incoming_room_message(const char *const nick, const char *const r
|
||||
gboolean mention, GList *triggers, int unread);
|
||||
void cons_show_incoming_message(const char *const short_from, const int win_index, int unread);
|
||||
void cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index, int unread);
|
||||
void cons_show_room_invites(GSList *invites);
|
||||
void cons_show_room_invites(GList *invites);
|
||||
void cons_show_received_subs(void);
|
||||
void cons_show_sent_subs(void);
|
||||
void cons_alert(void);
|
||||
|
||||
@@ -1073,15 +1073,15 @@ wins_create_summary(gboolean unread)
|
||||
}
|
||||
|
||||
char*
|
||||
win_autocomplete(const char *const search_str)
|
||||
win_autocomplete(const char *const search_str, gboolean previous)
|
||||
{
|
||||
return autocomplete_complete(wins_ac, search_str, TRUE);
|
||||
return autocomplete_complete(wins_ac, search_str, TRUE, previous);
|
||||
}
|
||||
|
||||
char*
|
||||
win_close_autocomplete(const char *const search_str)
|
||||
win_close_autocomplete(const char *const search_str, gboolean previous)
|
||||
{
|
||||
return autocomplete_complete(wins_close_ac, search_str, TRUE);
|
||||
return autocomplete_complete(wins_close_ac, search_str, TRUE, previous);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -91,9 +91,9 @@ gboolean wins_swap(int source_win, int target_win);
|
||||
void wins_hide_subwin(ProfWin *window);
|
||||
void wins_show_subwin(ProfWin *window);
|
||||
|
||||
char* win_autocomplete(const char *const search_str);
|
||||
char* win_autocomplete(const char *const search_str, gboolean previous);
|
||||
void win_reset_search_attempts(void);
|
||||
char* win_close_autocomplete(const char *const search_str);
|
||||
char* win_close_autocomplete(const char *const search_str, gboolean previous);
|
||||
void win_close_reset_search_attempts(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user