(input_is_empty): new WInput API.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-03-30 13:42:03 +03:00
parent 4d65a731c2
commit 0641e942e5
5 changed files with 15 additions and 8 deletions

View File

@ -1219,6 +1219,14 @@ input_assign_text (WInput * in, const char *text)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
gboolean
input_is_empty (const WInput * in)
{
return (in == NULL || in->buffer == NULL || in->buffer[0] == '\0');
}
/* --------------------------------------------------------------------------------------------- */
/* Inserts text in input line */ /* Inserts text in input line */
void void
input_insert (WInput * in, const char *text, gboolean insert_extra_space) input_insert (WInput * in, const char *text, gboolean insert_extra_space)

View File

@ -92,6 +92,7 @@ void input_set_default_colors (void);
cb_ret_t input_handle_char (WInput * in, int key); cb_ret_t input_handle_char (WInput * in, int key);
int input_key_is_in_map (WInput * in, int key); int input_key_is_in_map (WInput * in, int key);
void input_assign_text (WInput * in, const char *text); void input_assign_text (WInput * in, const char *text);
gboolean input_is_empty (const WInput * in);
void input_insert (WInput * in, const char *text, gboolean insert_extra_space); void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
void input_set_point (WInput * in, int pos); void input_set_point (WInput * in, int pos);
void input_update (WInput * in, gboolean clear_first); void input_update (WInput * in, gboolean clear_first);

View File

@ -672,7 +672,7 @@ view_filtered_cmd (void)
char *command; char *command;
const char *initial_command; const char *initial_command;
if (cmdline->buffer[0] == '\0') if (input_is_empty (cmdline))
initial_command = selection (current_panel)->fname; initial_command = selection (current_panel)->fname;
else else
initial_command = cmdline->buffer; initial_command = cmdline->buffer;

View File

@ -802,7 +802,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
*pattern = g_strdup (in_name->buffer); *pattern = g_strdup (in_name->buffer);
else else
*pattern = g_strdup (options.file_pattern ? "*" : ".*"); *pattern = g_strdup (options.file_pattern ? "*" : ".*");
*start_dir = in_start->buffer[0] != '\0' ? in_start->buffer : (char *) "."; *start_dir = !input_is_empty (in_start) ? in_start->buffer : (char *) ".";
if (in_start_dir != INPUT_LAST_TEXT) if (in_start_dir != INPUT_LAST_TEXT)
g_free (in_start_dir); g_free (in_start_dir);
in_start_dir = g_strdup (*start_dir); in_start_dir = g_strdup (*start_dir);

View File

@ -256,7 +256,7 @@ add2panelize (char *label, char *command)
static void static void
add2panelize_cmd (void) add2panelize_cmd (void)
{ {
if (pname->buffer != NULL && *pname->buffer != '\0') if (!input_is_empty (pname))
{ {
char *label; char *label;
@ -501,8 +501,6 @@ cd_panelize_cmd (void)
void void
external_panelize (void) external_panelize (void)
{ {
char *target = NULL;
if (!vfs_current_is_local ()) if (!vfs_current_is_local ())
{ {
message (D_ERROR, MSG_ERROR, _("Cannot run external panelize in a non-local directory")); message (D_ERROR, MSG_ERROR, _("Cannot run external panelize in a non-local directory"));
@ -533,11 +531,11 @@ external_panelize (void)
} }
case B_ENTER: case B_ENTER:
target = pname->buffer; if (!input_is_empty (pname))
if (target != NULL && *target)
{ {
char *cmd = g_strdup (target); char *cmd;
cmd = g_strdup (pname->buffer);
dlg_destroy (panelize_dlg); dlg_destroy (panelize_dlg);
do_external_panelize (cmd); do_external_panelize (cmd);
g_free (cmd); g_free (cmd);