mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(input_get_ctext): mew API.
Use it instead of direct access to WInput's buffer. (handle_cmdline_enter): additional minor refactoring. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
28154dc520
commit
79645187c6
@ -121,6 +121,21 @@ input_get_text (const WInput * in)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get pointer to input line buffer.
|
||||
*
|
||||
* @param in input line
|
||||
*
|
||||
* @return pointer to @in->buffer->str.
|
||||
*/
|
||||
static inline const char *
|
||||
input_get_ctext (const WInput * in)
|
||||
{
|
||||
return in->buffer->str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Is input line empty or not.
|
||||
*
|
||||
|
@ -599,7 +599,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
|
||||
case quick_input:
|
||||
if ((item->quick_widget->u.input.completion_flags & INPUT_COMPLETE_CD) != 0)
|
||||
*item->quick_widget->u.input.result =
|
||||
tilde_expand (INPUT (item->widget)->buffer->str);
|
||||
tilde_expand (input_get_ctext (INPUT (item->widget)));
|
||||
else
|
||||
*item->quick_widget->u.input.result = input_get_text (INPUT (item->widget));
|
||||
break;
|
||||
|
@ -622,7 +622,7 @@ view_filtered_cmd (const WPanel * panel)
|
||||
if (input_is_empty (cmdline))
|
||||
initial_command = selection (panel)->fname->str;
|
||||
else
|
||||
initial_command = cmdline->buffer->str;
|
||||
initial_command = input_get_ctext (cmdline);
|
||||
|
||||
command =
|
||||
input_dialog (_("Filtered view"),
|
||||
|
@ -81,11 +81,13 @@ static input_colors_t command_colors;
|
||||
static cb_ret_t
|
||||
enter (WInput * lc_cmdline)
|
||||
{
|
||||
const char *cmd = lc_cmdline->buffer->str;
|
||||
const char *cmd;
|
||||
|
||||
if (!command_prompt)
|
||||
return MSG_HANDLED;
|
||||
|
||||
cmd = input_get_ctext (lc_cmdline);
|
||||
|
||||
/* Any initial whitespace should be removed at this point */
|
||||
while (whiteness (*cmd))
|
||||
cmd++;
|
||||
|
@ -1460,12 +1460,12 @@ is_cmdline_mute (void)
|
||||
static gboolean
|
||||
handle_cmdline_enter (void)
|
||||
{
|
||||
size_t i;
|
||||
const char *s;
|
||||
|
||||
for (i = 0; i < cmdline->buffer->len && whitespace (cmdline->buffer->str[i]); i++)
|
||||
for (s = input_get_ctext (cmdline); *s != '\0' && whitespace (*s); s++)
|
||||
;
|
||||
|
||||
if (i != cmdline->buffer->len)
|
||||
if (*s != '\0')
|
||||
{
|
||||
send_message (cmdline, NULL, MSG_KEY, '\n', NULL);
|
||||
return TRUE;
|
||||
|
@ -501,7 +501,7 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi
|
||||
|
||||
/* check filename regexp */
|
||||
if (!file_pattern_cbox->state && !input_is_empty (in_name)
|
||||
&& !find_check_regexp (in_name->buffer->str))
|
||||
&& !find_check_regexp (input_get_ctext (in_name)))
|
||||
{
|
||||
/* Don't stop the dialog */
|
||||
widget_set_state (w, WST_ACTIVE, TRUE);
|
||||
@ -512,7 +512,7 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi
|
||||
|
||||
/* check content regexp */
|
||||
if (content_regexp_cbox->state && !content_is_empty
|
||||
&& !find_check_regexp (in_with->buffer->str))
|
||||
&& !find_check_regexp (input_get_ctext (in_with)))
|
||||
{
|
||||
/* Don't stop the dialog */
|
||||
widget_set_state (w, WST_ACTIVE, TRUE);
|
||||
@ -783,12 +783,15 @@ find_parameters (WPanel * panel, char **start_dir, ssize_t * start_dir_len,
|
||||
|
||||
case B_TREE:
|
||||
{
|
||||
const char *start_cstr;
|
||||
const char *temp_dir;
|
||||
|
||||
if (input_is_empty (in_start) || DIR_IS_DOT (in_start->buffer->str))
|
||||
start_cstr = input_get_ctext (in_start);
|
||||
|
||||
if (input_is_empty (in_start) || DIR_IS_DOT (start_cstr))
|
||||
temp_dir = vfs_path_as_str (panel->cwd_vpath);
|
||||
else
|
||||
temp_dir = in_start->buffer->str;
|
||||
temp_dir = start_cstr;
|
||||
|
||||
if (in_start_dir != INPUT_LAST_TEXT)
|
||||
g_free (in_start_dir);
|
||||
@ -828,7 +831,7 @@ find_parameters (WPanel * panel, char **start_dir, ssize_t * start_dir_len,
|
||||
*pattern = g_strdup (options.file_pattern ? "*" : ".*");
|
||||
else
|
||||
*pattern = input_get_text (in_name);
|
||||
*start_dir = !input_is_empty (in_start) ? in_start->buffer->str : (char *) ".";
|
||||
*start_dir = (char *) (!input_is_empty (in_start) ? input_get_ctext (in_start) : ".");
|
||||
if (in_start_dir != INPUT_LAST_TEXT)
|
||||
g_free (in_start_dir);
|
||||
in_start_dir = g_strdup (*start_dir);
|
||||
@ -859,7 +862,7 @@ find_parameters (WPanel * panel, char **start_dir, ssize_t * start_dir_len,
|
||||
}
|
||||
|
||||
if (!options.ignore_dirs_enable || input_is_empty (in_ignore)
|
||||
|| DIR_IS_DOT (in_ignore->buffer->str))
|
||||
|| DIR_IS_DOT (input_get_ctext (in_ignore)))
|
||||
*ignore_dirs = NULL;
|
||||
else
|
||||
*ignore_dirs = input_get_text (in_ignore);
|
||||
|
@ -1462,21 +1462,23 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
|
||||
|
||||
if (use_persistent_buffer)
|
||||
{
|
||||
const char *s;
|
||||
size_t i;
|
||||
int pos;
|
||||
|
||||
s = input_get_ctext (cmdline);
|
||||
|
||||
/* Check to make sure there are no non text characters in the command buffer,
|
||||
* such as tab, or newline, as this could cause problems. */
|
||||
for (i = 0; i < cmdline->buffer->len; i++)
|
||||
if ((unsigned char) cmdline->buffer->str[i] < 32
|
||||
|| (unsigned char) cmdline->buffer->str[i] == 127)
|
||||
if ((unsigned char) s[i] < 32 || (unsigned char) s[i] == 127)
|
||||
g_string_overwrite_len (cmdline->buffer, i, " ", 1);
|
||||
|
||||
/* Write the command buffer to the subshell. */
|
||||
write_all (mc_global.tty.subshell_pty, cmdline->buffer->str, cmdline->buffer->len);
|
||||
write_all (mc_global.tty.subshell_pty, s, cmdline->buffer->len);
|
||||
|
||||
/* Put the cursor in the correct place in the subshell. */
|
||||
pos = str_length (cmdline->buffer->str) - cmdline->point;
|
||||
pos = str_length (s) - cmdline->point;
|
||||
for (i = 0; i < (size_t) pos; i++)
|
||||
write_all (mc_global.tty.subshell_pty, ESC_STR "[D", 3);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user