mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +02:00
Added keyboard_entry_redirect() function to keyboard.[ch] which sends
the signal "gui entry redirect" signal. Added possibility to keep the entry hidden. /OPER [<nick> [<password>]] - syntax changed. If password isn't given, it's asked. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1063 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
d844880515
commit
596ef586b2
8 changed files with 105 additions and 21 deletions
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
static GString *entry;
|
||||
static int promptlen, permanent_prompt, pos, scrstart, scrpos;
|
||||
static int prompt_hidden;
|
||||
static char *prompt;
|
||||
|
||||
static void entry_screenpos(void)
|
||||
|
|
@ -54,7 +55,9 @@ static void entry_update(void)
|
|||
move(LINES-1, promptlen);
|
||||
|
||||
for (p = entry->str+scrstart, n = 0; n < len; n++, p++) {
|
||||
if ((unsigned char) *p >= 32)
|
||||
if (prompt_hidden)
|
||||
addch(' ');
|
||||
else if ((unsigned char) *p >= 32)
|
||||
addch((unsigned char) *p);
|
||||
else {
|
||||
set_color(stdscr, ATTR_REVERSE);
|
||||
|
|
@ -97,6 +100,11 @@ void gui_entry_set_perm_prompt(const char *str)
|
|||
gui_entry_set_prompt(NULL);
|
||||
}
|
||||
|
||||
void gui_entry_set_hidden(int hidden)
|
||||
{
|
||||
prompt_hidden = hidden;
|
||||
}
|
||||
|
||||
void gui_entry_remove_perm_prompt(void)
|
||||
{
|
||||
permanent_prompt = FALSE;
|
||||
|
|
@ -248,6 +256,7 @@ void gui_entry_init(void)
|
|||
pos = scrpos = 0;
|
||||
prompt = NULL; promptlen = 0;
|
||||
permanent_prompt = FALSE;
|
||||
prompt_hidden = FALSE;
|
||||
}
|
||||
|
||||
void gui_entry_deinit(void)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ void gui_entry_set_prompt(const char *str);
|
|||
/* permanent prompt can't be overwritten with gui_entry_set_prompt() */
|
||||
void gui_entry_set_perm_prompt(const char *str);
|
||||
void gui_entry_remove_perm_prompt(void);
|
||||
void gui_entry_set_hidden(int hidden);
|
||||
|
||||
void gui_entry_set_text(const char *str);
|
||||
char *gui_entry_get_text(void);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef void (*ENTRY_REDIRECT_ENTRY_FUNC) (const char *line, void *data, SERVER_
|
|||
|
||||
typedef struct {
|
||||
SIGNAL_FUNC func;
|
||||
int key;
|
||||
int flags;
|
||||
void *data;
|
||||
} ENTRY_REDIRECT_REC;
|
||||
|
||||
|
|
@ -75,12 +75,16 @@ static void handle_entry_redirect(const char *line)
|
|||
ENTRY_REDIRECT_ENTRY_FUNC func;
|
||||
void *data;
|
||||
|
||||
gui_entry_set_hidden(FALSE);
|
||||
|
||||
func = (ENTRY_REDIRECT_ENTRY_FUNC) redir->func;
|
||||
data = redir->data;
|
||||
g_free_and_null(redir);
|
||||
|
||||
if (func != NULL)
|
||||
func(line, data, active_win->active_server, active_win->active);
|
||||
if (func != NULL) {
|
||||
func(line, data, active_win->active_server,
|
||||
active_win->active);
|
||||
}
|
||||
|
||||
gui_entry_remove_perm_prompt();
|
||||
window_update_prompt();
|
||||
|
|
@ -158,6 +162,7 @@ void handle_key(int key)
|
|||
{
|
||||
const char *keyname;
|
||||
char *str;
|
||||
int add_history;
|
||||
|
||||
/* Quit if we get 5 CTRL-C's in a row. */
|
||||
if (key != CTRL('c'))
|
||||
|
|
@ -167,7 +172,7 @@ void handle_key(int key)
|
|||
|
||||
idle_time = time(NULL);
|
||||
|
||||
if (redir != NULL && redir->key) {
|
||||
if (redir != NULL && redir->flags & ENTRY_REDIRECT_FLAG_HOTKEY) {
|
||||
handle_key_redirect(key);
|
||||
return;
|
||||
}
|
||||
|
|
@ -218,12 +223,21 @@ void handle_key(int key)
|
|||
|
||||
translate_output(str);
|
||||
|
||||
if (redir == NULL)
|
||||
signal_emit("send command", 3, str, active_win->active_server, active_win->active);
|
||||
else
|
||||
add_history = TRUE;
|
||||
if (redir == NULL) {
|
||||
signal_emit("send command", 3, str,
|
||||
active_win->active_server,
|
||||
active_win->active);
|
||||
} else {
|
||||
if (redir->flags & ENTRY_REDIRECT_FLAG_HIDDEN)
|
||||
add_history = FALSE;
|
||||
handle_entry_redirect(str);
|
||||
}
|
||||
|
||||
command_history_add(active_win, gui_entry_get_text(), FALSE);
|
||||
if (add_history) {
|
||||
command_history_add(active_win, gui_entry_get_text(),
|
||||
FALSE);
|
||||
}
|
||||
gui_entry_set_text("");
|
||||
command_history_clear_pos(active_win);
|
||||
break;
|
||||
|
|
@ -531,13 +545,16 @@ static void sig_window_auto_changed(void)
|
|||
gui_entry_set_text("");
|
||||
}
|
||||
|
||||
static void sig_gui_entry_redirect(SIGNAL_FUNC func, const char *entry, gpointer key, void *data)
|
||||
static void sig_gui_entry_redirect(SIGNAL_FUNC func, const char *entry,
|
||||
void *flags, void *data)
|
||||
{
|
||||
redir = g_new0(ENTRY_REDIRECT_REC, 1);
|
||||
redir->func = func;
|
||||
redir->key = key != NULL;
|
||||
redir->flags = GPOINTER_TO_INT(flags);
|
||||
redir->data = data;
|
||||
|
||||
if (redir->flags & ENTRY_REDIRECT_FLAG_HIDDEN)
|
||||
gui_entry_set_hidden(TRUE);
|
||||
gui_entry_set_perm_prompt(entry);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue