Beispiel #1
0
static cb_ret_t
panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_NOTIFY:
        if (sender != NULL && sender->id == panel_listing_types_id)
        {
            WCheck *ch;
            WInput *in1, *in2, *in3;

            in1 = INPUT (dlg_find_by_id (h, panel_user_format_id));
            in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id));
            ch = CHECK (dlg_find_by_id (h, mini_user_status_id));
            in3 = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (!(ch->state & C_BOOL))
                input_assign_text (in3, status_format[RADIO (sender)->sel]);
            input_update (in1, FALSE);
            input_update (in2, FALSE);
            input_update (in3, FALSE);
            widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx);
            widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx);
            return MSG_HANDLED;
        }

        if (sender != NULL && sender->id == mini_user_status_id)
        {
            WInput *in;

            in = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (CHECK (sender)->state & C_BOOL)
            {
                widget_disable (WIDGET (in), FALSE);
                input_assign_text (in, status_format[3]);
            }
            else
            {
                WRadio *r;

                r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                widget_disable (WIDGET (in), TRUE);
                input_assign_text (in, status_format[r->sel]);
            }
            /* input_update (in, FALSE); */
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Beispiel #2
0
static void
update_command (void)
{
    if (l_panelize->pos != last_listitem)
    {
        struct panelize *data = NULL;

        last_listitem = l_panelize->pos;
        listbox_get_current (l_panelize, NULL, (void **) &data);
        input_assign_text (pname, data->command);
        pname->point = 0;
        input_update (pname, TRUE);
    }
}
Beispiel #3
0
static void
do_show_hist (WInput * in)
{
    size_t len;
    char *r;

    len = get_history_length (in->history);

    r = history_show (&in->history, &in->widget);
    if (r != NULL)
    {
        input_assign_text (in, r);
        g_free (r);
    }

    /* Has history cleaned up or not? */
    if (len != get_history_length (in->history))
        in->history_changed = TRUE;
}
Beispiel #4
0
static void
do_show_hist (WInput * in)
{
    size_t len;
    char *r;

    len = get_history_length (in->history.list);

    r = history_show (&in->history.list, WIDGET (in),
                      g_list_position (in->history.list, in->history.list));
    if (r != NULL)
    {
        input_assign_text (in, r);
        g_free (r);
    }

    /* Has history cleaned up or not? */
    if (len != get_history_length (in->history.list))
        in->history.changed = TRUE;
}
Beispiel #5
0
static cb_ret_t
display_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    switch (msg)
    {
    case DLG_KEY:
        if (parm == '\n')
        {
            if (dlg_widget_active (display_radio))
            {
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
                dlg_stop (h);
                return MSG_HANDLED;
            }

            if (dlg_widget_active (display_user_format))
            {
                h->ret_value = B_USER + 6;
                dlg_stop (h);
                return MSG_HANDLED;
            }

            if (dlg_widget_active (display_mini_status))
            {
                h->ret_value = B_USER + 7;
                dlg_stop (h);
                return MSG_HANDLED;
            }
        }

        if ((g_ascii_tolower (parm) == display_user_hotkey)
            && dlg_widget_active (display_user_format) && dlg_widget_active (display_mini_status))
        {
            display_radio->pos = display_radio->sel = 3;
            dlg_select_widget (display_radio);  /* force redraw */
            h->callback (h, (Widget *) display_radio, DLG_ACTION, 0, NULL);
            return MSG_HANDLED;
        }
        return MSG_NOT_HANDLED;

    case DLG_ACTION:
        if (sender == (Widget *) display_radio)
        {
            if (!(display_check_status->state & C_BOOL))
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
            input_update (display_mini_status, FALSE);
            input_update (display_user_format, FALSE);
            widget_disable (display_user_format->widget, display_radio->sel != 3);
            return MSG_HANDLED;
        }

        if (sender == (Widget *) display_check_status)
        {
            if (display_check_status->state & C_BOOL)
            {
                widget_disable (display_mini_status->widget, FALSE);
                input_assign_text (display_mini_status, displays_status[3]);
            }
            else
            {
                widget_disable (display_mini_status->widget, TRUE);
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
            }
            input_update (display_mini_status, FALSE);
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}
Beispiel #6
0
static cb_ret_t
panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_KEY:
        if (parm == '\n')
        {
            Widget *wi;

            wi = dlg_find_by_id (h, panel_listing_types_id);
            if (widget_is_active (wi))
            {
                WInput *in;

                in = INPUT (dlg_find_by_id (h, mini_user_format_id));
                input_assign_text (in, status_format[RADIO (wi)->sel]);
                dlg_stop (h);
                return MSG_HANDLED;
            }

            wi = dlg_find_by_id (h, panel_user_format_id);
            if (widget_is_active (wi))
            {
                h->ret_value = B_USER + 6;
                dlg_stop (h);
                return MSG_HANDLED;
            }

            wi = dlg_find_by_id (h, mini_user_format_id);
            if (widget_is_active (wi))
            {
                h->ret_value = B_USER + 7;
                dlg_stop (h);
                return MSG_HANDLED;
            }
        }

        if (g_ascii_tolower (parm) == listing_user_hotkey)
        {
            Widget *wi;

            wi = dlg_find_by_id (h, panel_user_format_id);
            if (widget_is_active (wi))
            {
                wi = dlg_find_by_id (h, mini_user_format_id);
                if (widget_is_active (wi))
                {
                    WRadio *r;

                    r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                    r->pos = r->sel = panel_listing_user_idx;
                    dlg_select_widget (WIDGET (r));     /* force redraw */
                    send_message (h, r, MSG_ACTION, 0, NULL);
                    return MSG_HANDLED;
                }
            }
        }
        return MSG_NOT_HANDLED;

    case MSG_ACTION:
        if (sender != NULL && sender->id == panel_listing_types_id)
        {
            WCheck *ch;
            WInput *in1, *in2, *in3;

            in1 = INPUT (dlg_find_by_id (h, panel_user_format_id));
            in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id));
            ch = CHECK (dlg_find_by_id (h, mini_user_status_id));
            in3 = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (!(ch->state & C_BOOL))
                input_assign_text (in3, status_format[RADIO (sender)->sel]);
            input_update (in1, FALSE);
            input_update (in2, FALSE);
            input_update (in3, FALSE);
            widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx);
            widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx);
            return MSG_HANDLED;
        }

        if (sender != NULL && sender->id == mini_user_status_id)
        {
            WInput *in;

            in = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (CHECK (sender)->state & C_BOOL)
            {
                widget_disable (WIDGET (in), FALSE);
                input_assign_text (in, status_format[3]);
            }
            else
            {
                WRadio *r;

                r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                widget_disable (WIDGET (in), TRUE);
                input_assign_text (in, status_format[r->sel]);
            }
            /* input_update (in, FALSE); */
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Beispiel #7
0
Datei: command.c Projekt: V07D/mc
static cb_ret_t
enter (WInput * lc_cmdline)
{
    char *cmd = lc_cmdline->buffer;

    if (!command_prompt)
        return MSG_HANDLED;

    /* Any initial whitespace should be removed at this point */
    while (*cmd == ' ' || *cmd == '\t' || *cmd == '\n')
        cmd++;

    if (!*cmd)
        return MSG_HANDLED;

    if (strncmp (cmd, "cd ", 3) == 0 || strcmp (cmd, "cd") == 0)
    {
        do_cd_command (cmd);
        input_clean (lc_cmdline);
        return MSG_HANDLED;
    }
    else if (strcmp (cmd, "exit") == 0)
    {
        input_assign_text (lc_cmdline, "");
        if (!quiet_quit_cmd ())
            return MSG_NOT_HANDLED;
    }
    else
    {
        GString *command;
        size_t i;

        if (!vfs_current_is_local ())
        {
            message (D_ERROR, MSG_ERROR, _("Cannot execute commands on non-local filesystems"));
            return MSG_NOT_HANDLED;
        }
#ifdef ENABLE_SUBSHELL
        /* Check this early before we clean command line
         * (will be checked again by shell_execute) */
        if (mc_global.tty.use_subshell && subshell_state != INACTIVE)
        {
            message (D_ERROR, MSG_ERROR, _("The shell is already running a command"));
            return MSG_NOT_HANDLED;
        }
#endif
        command = g_string_sized_new (32);

        for (i = 0; cmd[i] != '\0'; i++)
        {
            if (cmd[i] != '%')
                g_string_append_c (command, cmd[i]);
            else
            {
                char *s;

                s = expand_format (NULL, cmd[++i], TRUE);
                g_string_append (command, s);
                g_free (s);
            }
        }

        input_clean (lc_cmdline);
        shell_execute (command->str, 0);
        g_string_free (command, TRUE);

#ifdef ENABLE_SUBSHELL
        if ((quit & SUBSHELL_EXIT) != 0)
        {
            if (quiet_quit_cmd ())
                return MSG_HANDLED;

            quit = 0;
            /* restart subshell */
            if (mc_global.tty.use_subshell)
                init_subshell ();
        }

        if (mc_global.tty.use_subshell)
            do_load_prompt ();
#endif
    }
    return MSG_HANDLED;
}