Exemplo n.º 1
0
int
editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean cancel)
{
    int w, wq;
    int y = 2;
    WDialog *raw_dlg;

    w = str_term_width1 (heading) + 6;
    wq = str_term_width1 (query);
    w = MAX (w, wq + 3 * 2 + 1 + 2);

    raw_dlg =
        dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, WPOS_CENTER | WPOS_TRYUP, FALSE, dialog_colors,
                    editcmd_dialog_raw_key_query_cb, NULL, NULL, heading);
    widget_want_tab (WIDGET (raw_dlg), TRUE);

    add_widget (raw_dlg, label_new (y, 3, query));
    add_widget (raw_dlg, input_new (y++, 3 + wq + 1, input_colors,
                                    w - (6 + wq + 1), "", 0, INPUT_COMPLETE_NONE));
    if (cancel)
    {
        add_widget (raw_dlg, hline_new (y++, -1, -1));
        /* Button w/o hotkey to allow use any key as raw or macro one */
        add_widget_autopos (raw_dlg, button_new (y, 1, B_CANCEL, NORMAL_BUTTON, _("Cancel"), NULL),
                            WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
    }

    w = dlg_run (raw_dlg);
    dlg_destroy (raw_dlg);

    return (cancel && (w == ESC_CHAR || w == B_CANCEL)) ? 0 : w;
}
Exemplo n.º 2
0
rdpRdp* rdp_new(freerdp* instance)
{
	rdpRdp* rdp;

	rdp = (rdpRdp*) xzalloc(sizeof(rdpRdp));

	if (rdp != NULL)
	{
		rdp->instance = instance;
		rdp->settings = settings_new((void*) instance);
		if (instance != NULL)
			instance->settings = rdp->settings;
		rdp->extension = extension_new(instance);
		rdp->transport = transport_new(rdp->settings);
		rdp->license = license_new(rdp);
		rdp->input = input_new(rdp);
		rdp->update = update_new(rdp);
		rdp->fastpath = fastpath_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
		rdp->redirection = redirection_new();
		rdp->mppc = mppc_new(rdp);
	}

	return rdp;
}
Exemplo n.º 3
0
Arquivo: quick.c Projeto: idispatch/mc
static WInput *
quick_create_input (int y, int x, const quick_widget_t * qw)
{
    WInput *in;

    in = input_new (y, x, input_colors, 8, qw->u.input.text, qw->u.input.histname,
                    qw->u.input.completion_flags);

    in->is_password = qw->u.input.is_passwd;
    in->strip_password = qw->u.input.strip_passwd;

    return in;
}
Exemplo n.º 4
0
Arquivo: command.c Projeto: V07D/mc
WInput *
command_new (int y, int x, int cols)
{
    WInput *cmd;

    cmd = input_new (y, x, command_colors, cols, "", "cmdline",
                     INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES
                     | INPUT_COMPLETE_HOSTNAMES | INPUT_COMPLETE_CD | INPUT_COMPLETE_COMMANDS |
                     INPUT_COMPLETE_SHELL_ESC);

    /* Add our hooks */
    WIDGET (cmd)->callback = command_callback;

    return cmd;
}
Exemplo n.º 5
0
static int
input_fopen(const char *fname)
{
	FILE *fp;
	u_int p;

	if (fname[0] == '/' || fname[0] == '.' || fname[0] == '~') {
		if ((fp = tryopen(NULL, fname)) != NULL) {
			input_new(fp, NULL, fname);
			return (0);
		}

	} else {

		for (p = 0; paths[p] != NULL; p++)
			if ((fp = tryopen(paths[p], fname)) != NULL) {
				input_new(fp, paths[p], fname);
				return (0);
			}
	}

	warnx("cannot open '%s'", fname);
	return (-1);
}
Exemplo n.º 6
0
Arquivo: quick.c Projeto: rutsky/mc
static WInput *
quick_create_input (int y, int x, const quick_widget_t * qw)
{
    WInput *in;

    in = input_new (y, x, input_get_default_colors (), 8, qw->u.input.text, qw->u.input.histname,
                    INPUT_COMPLETE_DEFAULT);
    in->is_password = (qw->u.input.flags == 1);
    if ((qw->u.input.flags & 2) != 0)
        in->completion_flags |= INPUT_COMPLETE_CD;
    if ((qw->u.input.flags & 4) != 0)
        in->strip_password = TRUE;

    return in;
}
Exemplo n.º 7
0
Shell *
shell_new(void) {
    Shell *shell = (Shell *)malloc(sizeof (Shell));

    shell->cmd = NULL;

    shell->vt102 = vt102_new();

    shell->cli = cli_new(shell->vt102);

    shell->input = input_new(shell->vt102);

    xTaskCreate(shell_main, "SHELLx",  configMINIMAL_STACK_SIZE, shell, 8, &shell->task);

    return (shell);
}
Exemplo n.º 8
0
rdpRdp* rdp_new(rdpContext* context)
{
	rdpRdp* rdp;
	DWORD flags;

	rdp = (rdpRdp*) malloc(sizeof(rdpRdp));

	if (rdp)
	{
		ZeroMemory(rdp, sizeof(rdpRdp));

		rdp->context = context;
		rdp->instance = context->instance;

		flags = 0;

		if (context->ServerMode)
			flags |= FREERDP_SETTINGS_SERVER_MODE;

		if (!context->settings)
			context->settings = freerdp_settings_new(flags);

		rdp->settings = context->settings;
		rdp->settings->instance = context->instance;

		if (context->instance)
			context->instance->settings = rdp->settings;

		rdp->extension = extension_new(context->instance);
		rdp->transport = transport_new(rdp->settings);
		rdp->transport->rdp = rdp;
		rdp->license = license_new(rdp);
		rdp->input = input_new(rdp);
		rdp->update = update_new(rdp);
		rdp->fastpath = fastpath_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
		rdp->redirection = redirection_new();
		rdp->autodetect = autodetect_new();
		rdp->heartbeat = heartbeat_new();
		rdp->multitransport = multitransport_new();
		rdp->bulk = bulk_new(context);
	}

	return rdp;
}
Exemplo n.º 9
0
Arquivo: engine.c Projeto: fizx/sit
void
engine_replay_journal(Engine *engine) {
  if(!engine->data_dir) return;

  glob_t g;
  char *pattern;

  asprintf(&pattern, "%.*s/[0-9]*.log", engine->data_dir->len, engine->data_dir->val);
  
  int status = glob(pattern, 0, NULL, &g);
  if(status || !g.gl_pathc) {
    INFO("Can't glob: %d", status);
    return;
  }
  pstring nl = {"\n", 1};

	Input *input = input_new(engine, BUF_SIZE);
  input->output = malloc(sizeof(Output));
  input->output->write = _log_write;
  ProtocolParser *pparser = line_input_protocol_new(input);
  pstring *pstr = pstring_new(BUF_SIZE);
  
  for(int i = 0; i < g.gl_pathc; i++) {
    char *path = g.gl_pathv[i];
    DEBUG("found %s", path);
    FILE *file = fopen(path, "r");
    if(!file) {
      ERR("can't open %s", path);
    } else {
    
      int nread =0;
      while ((pstr->len = fread(pstr->val, 1, BUF_SIZE, file))) {
        pparser->consume(pparser, pstr);
    	}
      fclose(file);
    }
  }
  
  pstring_free(pstr);

  line_input_protocol_free(pparser);
  free(input->output);
	input_free(input);  
}
Exemplo n.º 10
0
WInput *
command_new (int y, int x, int cols)
{
    WInput *cmd;
    const input_colors_t command_colors = {
        DEFAULT_COLOR,
        COMMAND_MARK_COLOR,
        DEFAULT_COLOR,
        COMMAND_HISTORY_COLOR
    };

    cmd = input_new (y, x, (int *) command_colors, cols, "", "cmdline",
                     INPUT_COMPLETE_DEFAULT | INPUT_COMPLETE_CD | INPUT_COMPLETE_COMMANDS |
                     INPUT_COMPLETE_SHELL_ESC);

    /* Add our hooks */
    cmd->widget.callback = command_callback;

    return cmd;
}
Exemplo n.º 11
0
WInput *
command_new (int y, int x, int cols)
{
    WInput *cmd;
    const input_colors_t command_colors = {
        DEFAULT_COLOR,
        COMMAND_MARK_COLOR,
        DEFAULT_COLOR,
        COMMAND_HISTORY_COLOR
    };

    cmd = input_new (y, x, (int *) command_colors, cols, "", "cmdline",
                     INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES
                     | INPUT_COMPLETE_HOSTNAMES | INPUT_COMPLETE_CD | INPUT_COMPLETE_COMMANDS |
                     INPUT_COMPLETE_SHELL_ESC);

    /* Add our hooks */
    WIDGET (cmd)->callback = command_callback;

    return cmd;
}
Exemplo n.º 12
0
rdpRdp* rdp_new()
{
	rdpRdp* rdp;

	rdp = (rdpRdp*) xzalloc(sizeof(rdpRdp));

	if (rdp != NULL)
	{
		rdp->licensed = False;
		rdp->settings = settings_new();
		rdp->registry = registry_new(rdp->settings);
		rdp->transport = transport_new(rdp->settings);
		rdp->license = license_new(rdp);
		rdp->input = input_new(rdp);
		rdp->update = update_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
	}

	return rdp;
}
Exemplo n.º 13
0
int
editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel)
{
    int w = str_term_width1 (query) + 7;
    struct Dlg_head *raw_dlg =
        create_dlg (0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
                    NULL, heading,
                    DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
    add_widget (raw_dlg,
                input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, INPUT_COMPLETE_DEFAULT));
    add_widget (raw_dlg, label_new (3 - cancel, 2, query));
    if (cancel)
        add_widget (raw_dlg, button_new (4, w / 2 - 5, B_CANCEL, NORMAL_BUTTON, _("Cancel"), 0));
    w = run_dlg (raw_dlg);
    destroy_dlg (raw_dlg);
    if (cancel) {
        if (w == XCTRL ('g') || w == XCTRL ('c') || w == ESC_CHAR || w == B_CANCEL)
            return 0;
    }

    return w;
}
Exemplo n.º 14
0
static void
init_panelize (void)
{
    int i, panelize_cols = COLS - 6;
    struct panelize *current = panelize;

#ifdef ENABLE_NLS
    static int i18n_flag = 0;
    static int maxlen = 0;

    if (!i18n_flag)
    {
        i = sizeof (panelize_but) / sizeof (panelize_but[0]);
        while (i--)
        {
            panelize_but[i].text = _(panelize_but[i].text);
            maxlen += str_term_width1 (panelize_but[i].text) + 5;
        }
        maxlen += 10;

        i18n_flag = 1;
    }
    panelize_cols = max (panelize_cols, maxlen);

    panelize_but[2].x = panelize_but[3].x + str_term_width1 (panelize_but[3].text) + 7;
    panelize_but[1].x = panelize_but[2].x + str_term_width1 (panelize_but[2].text) + 5;
    panelize_but[0].x = panelize_cols - str_term_width1 (panelize_but[0].text) - 8 - BX;

#endif /* ENABLE_NLS */

    last_listitem = 0;

    do_refresh ();

    panelize_dlg =
        create_dlg (TRUE, 0, 0, 22, panelize_cols, dialog_colors,
                    panelize_callback, "[External panelize]",
                    _("External panelize"), DLG_CENTER | DLG_REVERSE);

    for (i = 0; i < BUTTONS; i++)
        add_widget (panelize_dlg,
                    button_new (BY + panelize_but[i].y,
                                BX + panelize_but[i].x,
                                panelize_but[i].ret_cmd,
                                panelize_but[i].flags, panelize_but[i].text, 0));

    pname =
        input_new (UY + 14, UX, input_get_default_colors (),
                   panelize_dlg->cols - 10, "", "in", INPUT_COMPLETE_DEFAULT);
    add_widget (panelize_dlg, pname);

    add_widget (panelize_dlg, label_new (UY + 13, UX, _("Command")));

    /* get new listbox */
    l_panelize = listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, FALSE, NULL);

    while (current)
    {
        listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);
        current = current->next;
    }

    /* add listbox to the dialogs */
    add_widget (panelize_dlg, l_panelize);

    listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command")));
}
Exemplo n.º 15
0
static Dlg_head *
display_init (int radio_sel, char *init_text, int _check_status, char **_status)
{
    int dlg_width = 48, dlg_height = 15;
    Dlg_head *dd;

    /* Controls whether the array strings have been translated */
    const char *displays[LIST_TYPES] = {
        N_("&Full file list"),
        N_("&Brief file list"),
        N_("&Long file list"),
        N_("&User defined:")
    };

    /* Index in displays[] for "user defined" */
    const int user_type_idx = 3;

    const char *display_title = N_("Listing mode");
    const char *user_mini_status = N_("User &mini status");
    const char *ok_name = N_("&OK");
    const char *cancel_name = N_("&Cancel");

    WButton *ok_button, *cancel_button;

    {
        int i, maxlen = 0;
        const char *cp;
        int ok_len, cancel_len, b_len, gap;

#ifdef ENABLE_NLS
        display_title = _(display_title);
        user_mini_status = _(user_mini_status);
        ok_name = _(ok_name);
        cancel_name = _(cancel_name);

        for (i = 0; i < LIST_TYPES; i++)
            displays[i] = _(displays[i]);
#endif

        /* get hotkey of user-defined format string */
        cp = strchr (displays[user_type_idx], '&');
        if (cp != NULL && *++cp != '\0')
            display_user_hotkey = g_ascii_tolower (*cp);

        /* xpos will be fixed later */
        ok_button = button_new (dlg_height - 3, 0, B_ENTER, DEFPUSH_BUTTON, ok_name, 0);
        ok_len = button_get_len (ok_button);
        cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0);
        cancel_len = button_get_len (cancel_button);
        b_len = ok_len + cancel_len + 2;

        dlg_width = max (dlg_width, str_term_width1 (display_title) + 10);
        /* calculate max width of radiobutons */
        for (i = 0; i < LIST_TYPES; i++)
            maxlen = max (maxlen, str_term_width1 (displays[i]));
        dlg_width = max (dlg_width, maxlen);
        dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13);

        /* buttons */
        dlg_width = max (dlg_width, b_len + 6);
        gap = (dlg_width - 6 - b_len) / 3;
        ok_button->widget.x = 3 + gap;
        cancel_button->widget.x = ok_button->widget.x + ok_len + gap + 2;
    }

    displays_status = _status;

    dd = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors,
                     display_callback, "[Listing Mode...]", display_title,
                     DLG_CENTER | DLG_REVERSE);

    add_widget (dd, cancel_button);
    add_widget (dd, ok_button);

    display_mini_status =
        input_new (10, 8, input_get_default_colors (), dlg_width - 12, _status[radio_sel],
                   "mini-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_mini_status);

    display_check_status = check_new (9, 4, _check_status, user_mini_status);
    add_widget (dd, display_check_status);

    display_user_format = input_new (7, 8, input_get_default_colors (), dlg_width - 12, init_text,
                                     "user-fmt-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_user_format);

    display_radio = radio_new (3, 4, LIST_TYPES, displays);
    display_radio->sel = display_radio->pos = radio_sel;
    add_widget (dd, display_radio);

    return dd;
}
Exemplo n.º 16
0
Arquivo: quick.c Projeto: BrEacK/mc
int
quick_dialog_skip (QuickDialog * qd, int nskip)
{
#ifdef ENABLE_NLS
#define I18N(x) (x = !qd->i18n && x != NULL && *x != '\0' ? _(x): x)
#else
#define I18N(x) (x = x)
#endif
    Dlg_head *dd;
    QuickWidget *qw;
    WInput *in;
    WRadio *r;
    int return_val;

    I18N (qd->title);

    if ((qd->xpos == -1) || (qd->ypos == -1))
        dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen,
                         dialog_colors, qd->callback, qd->mouse, qd->help, qd->title,
                         DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
    else
        dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
                         dialog_colors, qd->callback, qd->mouse, qd->help, qd->title, DLG_REVERSE);

    for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
    {
        int xpos;
        int ypos;

        xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
        ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;

        switch (qw->widget_type)
        {
        case quick_checkbox:
            qw->widget =
                (Widget *) check_new (ypos, xpos, *qw->u.checkbox.state,
                                      I18N (qw->u.checkbox.text));
            break;

        case quick_button:
            qw->widget = (Widget *) button_new (ypos, xpos, qw->u.button.action,
                                                (qw->u.button.action ==
                                                 B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
                                                I18N (qw->u.button.text), qw->u.button.callback);
            break;

        case quick_input:
            in = input_new (ypos, xpos, input_get_default_colors (),
                            qw->u.input.len, qw->u.input.text, qw->u.input.histname,
                            INPUT_COMPLETE_DEFAULT);
            in->is_password = (qw->u.input.flags == 1);
            if ((qw->u.input.flags & 2) != 0)
                in->completion_flags |= INPUT_COMPLETE_CD;
            if ((qw->u.input.flags & 4) != 0)
                in->strip_password = TRUE;
            qw->widget = (Widget *) in;
            *qw->u.input.result = NULL;
            break;

        case quick_label:
            qw->widget = (Widget *) label_new (ypos, xpos, I18N (qw->u.label.text));
            break;

        case quick_groupbox:
            qw->widget = (Widget *) groupbox_new (ypos, xpos,
                                                  qw->u.groupbox.height,
                                                  qw->u.groupbox.width,
                                                  I18N (qw->u.groupbox.title));
            break;

        case quick_radio:
            {
                int i;
                char **items = NULL;

                /* create the copy of radio_items to avoid mwmory leak */
                items = g_new0 (char *, qw->u.radio.count + 1);

                if (!qd->i18n)
                    for (i = 0; i < qw->u.radio.count; i++)
                        items[i] = g_strdup (_(qw->u.radio.items[i]));
                else
                    for (i = 0; i < qw->u.radio.count; i++)
                        items[i] = g_strdup (qw->u.radio.items[i]);

                r = radio_new (ypos, xpos, qw->u.radio.count, (const char **) items);
                r->pos = r->sel = *qw->u.radio.value;
                qw->widget = (Widget *) r;
                g_strfreev (items);
                break;
            }

        default:
            qw->widget = NULL;
            fprintf (stderr, "QuickWidget: unknown widget type\n");
            break;
        }

        if (qw->widget != NULL)
        {
            qw->widget->options |= qw->options; /* FIXME: cannot reset flags, setup only */
            add_widget (dd, qw->widget);
        }
    }

    while (nskip-- != 0)
    {
        dd->current = g_list_next (dd->current);
        if (dd->current == NULL)
            dd->current = dd->widgets;
    }

    return_val = run_dlg (dd);

    /* Get the data if we found something interesting */
    if (return_val != B_CANCEL)
    {
        for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
        {
            switch (qw->widget_type)
            {
            case quick_checkbox:
                *qw->u.checkbox.state = ((WCheck *) qw->widget)->state & C_BOOL;
                break;

            case quick_input:
                if ((qw->u.input.flags & 2) != 0)
                    *qw->u.input.result = tilde_expand (((WInput *) qw->widget)->buffer);
                else
                    *qw->u.input.result = g_strdup (((WInput *) qw->widget)->buffer);
                break;

            case quick_radio:
                *qw->u.radio.value = ((WRadio *) qw->widget)->sel;
                break;

            default:
                break;
            }
        }
    }

    destroy_dlg (dd);

    return return_val;
#undef I18N
}
Exemplo n.º 17
0
rdpRdp* rdp_new(rdpContext* context)
{
    rdpRdp* rdp;
    DWORD flags;
    BOOL newSettings = FALSE;

    rdp = (rdpRdp*) calloc(1, sizeof(rdpRdp));
    if (!rdp)
        return NULL;

    rdp->context = context;
    rdp->instance = context->instance;

    flags = 0;

    if (context->ServerMode)
        flags |= FREERDP_SETTINGS_SERVER_MODE;

    if (!context->settings)
    {
        context->settings = freerdp_settings_new(flags);
        if (!context->settings)
            goto out_free;
        newSettings = TRUE;
    }

    rdp->settings = context->settings;
    rdp->settings->instance = context->instance;

    if (context->instance)
        context->instance->settings = rdp->settings;

    rdp->transport = transport_new(rdp->settings);
    if (!rdp->transport)
        goto out_free_settings;

    rdp->transport->rdp = rdp;

    rdp->license = license_new(rdp);
    if (!rdp->license)
        goto out_free_transport;

    rdp->input = input_new(rdp);
    if (!rdp->input)
        goto out_free_license;

    rdp->update = update_new(rdp);
    if (!rdp->update)
        goto out_free_input;

    rdp->fastpath = fastpath_new(rdp);
    if (!rdp->fastpath)
        goto out_free_update;

    rdp->nego = nego_new(rdp->transport);
    if (!rdp->nego)
        goto out_free_fastpath;

    rdp->mcs = mcs_new(rdp->transport);
    if (!rdp->mcs)
        goto out_free_nego;

    rdp->redirection = redirection_new();
    if (!rdp->redirection)
        goto out_free_mcs;

    rdp->autodetect = autodetect_new();
    if (!rdp->autodetect)
        goto out_free_redirection;

    rdp->heartbeat = heartbeat_new();
    if (!rdp->heartbeat)
        goto out_free_autodetect;

    rdp->multitransport = multitransport_new();
    if (!rdp->multitransport)
        goto out_free_heartbeat;

    rdp->bulk = bulk_new(context);
    if (!rdp->bulk)
        goto out_free_multitransport;

    return rdp;

out_free_multitransport:
    multitransport_free(rdp->multitransport);
out_free_heartbeat:
    heartbeat_free(rdp->heartbeat);
out_free_autodetect:
    autodetect_free(rdp->autodetect);
out_free_redirection:
    redirection_free(rdp->redirection);
out_free_mcs:
    mcs_free(rdp->mcs);
out_free_nego:
    nego_free(rdp->nego);
out_free_fastpath:
    fastpath_free(rdp->fastpath);
out_free_update:
    update_free(rdp->update);
out_free_input:
    input_free(rdp->input);
out_free_license:
    license_free(rdp->license);
out_free_transport:
    transport_free(rdp->transport);
out_free_settings:
    if (newSettings)
        freerdp_settings_free(rdp->settings);
out_free:
    free(rdp);
    return NULL;
}
Exemplo n.º 18
0
static void
display_init (int radio_sel, char *init_text,
	      int _check_status, char ** _status)
{
	char* user_mini_status = _("user &Mini status");
	char* ok_button = _("&Ok");
	char* cancel_button = _("&Cancel");
	
	static int button_start = 30;
	
    displays_status = _status;

    if (!i18n_displays_flag){
		int i, l, maxlen = 0;
		char* cp;

 		display_title = _(display_title);
		for (i = 0; i < LIST_TYPES; i++)
		{
		    displays [i] = _(displays [i]);
			if ((l = strlen(displays [i])) > maxlen)
				maxlen = l;
		}

		i = strlen (ok_button) + 5;
		l = strlen (cancel_button) + 3;
		l = max(i, l);

		i = maxlen + l + 16;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		i = strlen (user_mini_status) + 13;
		if (i > DISPLAY_X)
			DISPLAY_X = i;
			
		i = strlen (display_title) + 8;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		button_start = DISPLAY_X - l - 5;
		
		/* get hotkey of user-defined format string */
		cp = strchr(displays[LIST_TYPES-1],'&');
		if (cp != NULL && *++cp != '\0')
			user_hotkey = tolower(*cp);

        i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Left and Right Menus]", "display",
		     DLG_CENTER | DLG_GRID);

    x_set_dialog_title (dd, _("Listing mode"));
    add_widgetl (dd,
        button_new (4, button_start, B_CANCEL, 
			NORMAL_BUTTON, cancel_button, 0, 0, "cancel-button"),
	XV_WLAY_RIGHTOF);

    add_widgetl (dd,
		button_new (3, button_start, B_ENTER, 
			DEFPUSH_BUTTON, ok_button, 0, 0, "ok-button"),
	 XV_WLAY_CENTERROW);

    status = input_new (10, 9, INPUT_COLOR, DISPLAY_X-14, _status [radio_sel], "mini-input");
    add_widgetl (dd, status, XV_WLAY_RIGHTDOWN);
    input_set_point (status, 0);

    check_status = check_new (9, 5, _check_status, user_mini_status, "mini-status");
    add_widgetl (dd, check_status, XV_WLAY_NEXTROW);
    
    user = input_new  (7, 9, INPUT_COLOR, DISPLAY_X-14, init_text, "user-fmt-input");
    add_widgetl (dd, user, XV_WLAY_RIGHTDOWN);
    input_set_point (user, 0);

#ifdef PORT_HAS_ICON_VIEW
    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1, "radio");
#else
    my_radio = radio_new (3, 5, LIST_TYPES-1, displays, 1, "radio");
#endif
    my_radio->sel = my_radio->pos = current_mode;
    add_widgetl (dd, my_radio, XV_WLAY_BELOWCLOSE);
}
Exemplo n.º 19
0
Arquivo: panelize.c Projeto: andi5/mc
static void
init_panelize (void)
{
    struct
    {
        int ret_cmd;
        button_flags_t flags;
        const char *text;
    } panelize_but[] =
    {
        /* *INDENT-OFF* */
        { B_ENTER, DEFPUSH_BUTTON, N_("Pane&lize") },
        { B_REMOVE, NORMAL_BUTTON, N_("&Remove") },
        { B_ADD, NORMAL_BUTTON, N_("&Add new") },
        { B_CANCEL, NORMAL_BUTTON, N_("&Cancel") }
        /* *INDENT-ON* */
    };

    size_t i;
    int blen;
    int panelize_cols;
    struct panelize *current;
    int x, y;

    last_listitem = 0;

    do_refresh ();

    i = G_N_ELEMENTS (panelize_but);
    blen = i - 1;               /* gaps between buttons */
    while (i-- != 0)
    {
#ifdef ENABLE_NLS
        panelize_but[i].text = _(panelize_but[i].text);
#endif
        blen += str_term_width1 (panelize_but[i].text) + 3 + 1;
        if (panelize_but[i].flags == DEFPUSH_BUTTON)
            blen += 2;
    }

    panelize_cols = COLS - 6;
    panelize_cols = max (panelize_cols, blen + 4);

    panelize_dlg =
        dlg_create (TRUE, 0, 0, 20, panelize_cols, dialog_colors, panelize_callback, NULL,
                    "[External panelize]", _("External panelize"), DLG_CENTER);

    /* add listbox to the dialogs */
    y = UY;
    add_widget (panelize_dlg, groupbox_new (y++, UX, 12, panelize_cols - UX * 2, ""));

    l_panelize = listbox_new (y, UX + 1, 10, panelize_cols - UX * 2 - 2, FALSE, NULL);
    for (current = panelize; current != NULL; current = current->next)
        listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);
    listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command")));
    add_widget (panelize_dlg, l_panelize);

    y += WIDGET (l_panelize)->lines + 1;
    add_widget (panelize_dlg, label_new (y++, UX, _("Command")));
    pname =
        input_new (y++, UX, input_colors, panelize_cols - UX * 2, "", "in",
                   INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES | INPUT_COMPLETE_COMMANDS |
                   INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES | INPUT_COMPLETE_CD |
                   INPUT_COMPLETE_SHELL_ESC);
    add_widget (panelize_dlg, pname);



    add_widget (panelize_dlg, hline_new (y++, -1, -1));

    x = (panelize_cols - blen) / 2;
    for (i = 0; i < G_N_ELEMENTS (panelize_but); i++)
    {
        WButton *b;

        b = button_new (y, x,
                        panelize_but[i].ret_cmd, panelize_but[i].flags, panelize_but[i].text, NULL);
        add_widget (panelize_dlg, b);

        x += button_get_len (b) + 1;
    }

    dlg_select_widget (l_panelize);
}
Exemplo n.º 20
0
static int
find_parameters (char **start_dir, char **pattern, char **content)
{
    int return_value;
    char *temp_dir;
    static char *in_contents = NULL;
    static char *in_start_dir = NULL;
    static char *in_start_name = NULL;

	static char* labs[] = {N_("Start at:"), N_("Filename:"), N_("Content: ")};
	static char* buts[] = {N_("&Ok"), N_("&Tree"), N_("&Cancel")};
	static int ilen = 30, istart = 14;
	static int b0 = 3, b1 = 16, b2 = 36;

#ifdef ENABLE_NLS
	static int i18n_flag = 0;
	
	if (!i18n_flag)
	{
		register int i = sizeof(labs)/sizeof(labs[0]);
		int l1, maxlen = 0;
		
		while (i--)
		{
			l1 = strlen (labs [i] = _(labs [i]));
			if (l1 > maxlen)
				maxlen = l1;
		}
		i = maxlen + ilen + 7;
		if (i > FIND_X)
			FIND_X = i;
		
		for (i = sizeof(buts)/sizeof(buts[0]), l1 = 0; i--; )
		{
			l1 += strlen (buts [i] = _(buts [i]));
		}
		l1 += 21;
		if (l1 > FIND_X)
			FIND_X = l1;

		ilen = FIND_X - 7 - maxlen; /* for the case of very long buttons :) */
		istart = FIND_X - 3 - ilen;
		
		b1 = b0 + strlen(buts[0]) + 7;
		b2 = FIND_X - (strlen(buts[2]) + 6);
		
		i18n_flag = 1;
	}
	
#endif /* ENABLE_NLS */

find_par_start:
    if (!in_start_dir)
	in_start_dir = strdup (".");
    if (!in_start_name)
	in_start_name = strdup (easy_patterns ? "*" : ".");
    if (!in_contents)
	in_contents = strdup ("");
    
    find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
			   common_dialog_callback, "[Find File]", "findfile",
			   DLG_CENTER | DLG_GRID);
    x_set_dialog_title (find_dlg, _("Find File"));

	add_widgetl (find_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
		buts[2], 0 ,0, "cancel"), XV_WLAY_RIGHTOF);
#ifndef HAVE_GNOME
	add_widgetl (find_dlg, button_new (9, b1, B_TREE, NORMAL_BUTTON,
		buts[1], 0, 0, "tree"), XV_WLAY_RIGHTOF);
#endif
	add_widgetl (find_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
		buts[0], 0, 0, "ok"), XV_WLAY_CENTERROW);

	in_with  = input_new (7, istart, INPUT_COLOR, ilen,	in_contents, "content");
    add_widgetl (find_dlg, in_with, XV_WLAY_BELOWOF);

	in_name  = input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name");
    add_widgetl (find_dlg, in_name, XV_WLAY_BELOWOF);

	in_start = input_new (3, istart, INPUT_COLOR, ilen,	in_start_dir, "start");
    add_widgetl (find_dlg, in_start, XV_WLAY_NEXTCOLUMN);

	add_widgetl (find_dlg, label_new (7, 3, labs[2], "label-cont"), XV_WLAY_BELOWOF);
	add_widgetl (find_dlg, label_new (5, 3, labs[1], "label-file"), XV_WLAY_BELOWOF);
	add_widgetl (find_dlg, label_new (3, 3, labs[0], "label-start"), XV_WLAY_NEXTCOLUMN);

    run_dlg (find_dlg);

    switch (find_dlg->ret_value){
    case B_CANCEL:
	return_value = 0;
	break;

#ifndef HAVE_GNOME
    case B_TREE:
	temp_dir = strdup (in_start->buffer);
	destroy_dlg (find_dlg);
	free (in_start_dir);
	if (strcmp (temp_dir, ".") == 0){
	    free (temp_dir);
	    temp_dir = strdup (cpanel->cwd);
	}
	in_start_dir = tree (temp_dir);
	if (in_start_dir)
	    free (temp_dir);
	else
	    in_start_dir = temp_dir;
	/* Warning: Dreadful goto */
	goto find_par_start;
	break;
#endif
	
    default:
	return_value = 1;
	*start_dir = strdup (in_start->buffer);
	*pattern   = strdup (in_name->buffer);

	free (in_contents);
	if (in_with->buffer [0]){
	    *content    = strdup (in_with->buffer);
	    in_contents = strdup (*content);
	} else 
	    *content = in_contents = NULL;

	free (in_start_dir);
	in_start_dir = strdup (*start_dir);
	free (in_start_name);
	in_start_name = strdup (*pattern);
    }

    destroy_dlg (find_dlg);
			 
    return return_value;
}
Exemplo n.º 21
0
static void
display_init (int radio_sel, char *init_text, int _check_status,
	      char **_status)
{
    static const char *display_title = N_("Listing mode");
    static int i18n_displays_flag;
    const char *user_mini_status = _("user &Mini status");
    const char *ok_button = _("&OK");
    const char *cancel_button = _("&Cancel");

    static int button_start = 30;

    displays_status = _status;

    if (!i18n_displays_flag) {
	int i, l, maxlen = 0;
	const char *cp;

	display_title = _(display_title);
	for (i = 0; i < LIST_TYPES; i++) {
	    displays[i] = _(displays[i]);
	    if ((l = strlen (displays[i])) > maxlen)
		maxlen = l;
	}

	i = strlen (ok_button) + 5;
	l = strlen (cancel_button) + 3;
	l = max (i, l);

	i = maxlen + l + 16;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (user_mini_status) + 13;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (display_title) + 10;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	button_start = DISPLAY_X - l - 5;

	/* get hotkey of user-defined format string */
	cp = strchr (displays[USER_TYPE], '&');
	if (cp != NULL && *++cp != '\0')
	    user_hotkey = tolower (*cp);

	i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Listing Mode...]", display_title,
		     DLG_CENTER | DLG_REVERSE);

    add_widget (dd,
		button_new (4, button_start, B_CANCEL, NORMAL_BUTTON,
			    cancel_button, 0));

    add_widget (dd,
		button_new (3, button_start, B_ENTER, DEFPUSH_BUTTON,
			    ok_button, 0));

    status =
	input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
		   "mini-input");
    add_widget (dd, status);
    input_set_point (status, 0);

    check_status =
	check_new (9, 5, _check_status, user_mini_status);
    add_widget (dd, check_status);

    user =
	input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
		   "user-fmt-input");
    add_widget (dd, user);
    input_set_point (user, 0);

    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1);
    my_radio->sel = my_radio->pos = current_mode;
    add_widget (dd, my_radio);
}
Exemplo n.º 22
0
/*
 * find_parameters: gets information from the user
 *
 * If the return value is true, then the following holds:
 *
 * START_DIR and PATTERN are pointers to char * and upon return they
 * contain the information provided by the user.
 *
 * CONTENT holds a strdup of the contents specified by the user if he
 * asked for them or 0 if not (note, this is different from the
 * behavior for the other two parameters.
 *
 */
static int
find_parameters (char **start_dir, char **pattern, char **content)
{
    int return_value;
    char *temp_dir;
    static const char *case_label = N_("case &Sensitive");

    static char *in_contents = NULL;
    static char *in_start_dir = NULL;
    static char *in_start_name = NULL;

    static const char *labs[] =
	{ N_("Start at:"), N_("Filename:"), N_("Content: ") };
    static const char *buts[] = { N_("&OK"), N_("&Tree"), N_("&Cancel") };
    static int ilen = 30, istart = 14;
    static int b0 = 3, b1 = 16, b2 = 36;

#ifdef ENABLE_NLS
    static int i18n_flag = 0;

    if (!i18n_flag) {
	register int i = sizeof (labs) / sizeof (labs[0]);
	int l1, maxlen = 0;

	while (i--) {
	    l1 = strlen (labs[i] = _(labs[i]));
	    if (l1 > maxlen)
		maxlen = l1;
	}
	i = maxlen + ilen + 7;
	if (i > FIND_X)
	    FIND_X = i;

	for (i = sizeof (buts) / sizeof (buts[0]), l1 = 0; i--;) {
	    l1 += strlen (buts[i] = _(buts[i]));
	}
	l1 += 21;
	if (l1 > FIND_X)
	    FIND_X = l1;

	ilen = FIND_X - 7 - maxlen;	/* for the case of very long buttons :) */
	istart = FIND_X - 3 - ilen;

	b1 = b0 + strlen (buts[0]) + 7;
	b2 = FIND_X - (strlen (buts[2]) + 6);

	i18n_flag = 1;
	case_label = _(case_label);
    }
#endif				/* ENABLE_NLS */

  find_par_start:
    if (!in_start_dir)
	in_start_dir = g_strdup (".");
    if (!in_start_name)
	in_start_name = g_strdup (easy_patterns ? "*" : ".");
    if (!in_contents)
	in_contents = g_strdup ("");

    find_dlg =
	create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
		    find_parm_callback, "[Find File]", _("Find File"),
		    DLG_CENTER | DLG_REVERSE);

    add_widget (find_dlg,
		button_new (11, b2, B_CANCEL, NORMAL_BUTTON, buts[2], 0));
    add_widget (find_dlg,
		button_new (11, b1, B_TREE, NORMAL_BUTTON, buts[1], 0));
    add_widget (find_dlg,
		button_new (11, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0));

    case_sense = check_new (9, 3, case_sensitive, case_label);
    add_widget (find_dlg, case_sense);

    in_with =
	input_new (7, istart, INPUT_COLOR, ilen, in_contents, "content");
    add_widget (find_dlg, in_with);

    in_name =
	input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name");
    add_widget (find_dlg, in_name);

    in_start =
	input_new (3, istart, INPUT_COLOR, ilen, in_start_dir, "start");
    add_widget (find_dlg, in_start);

    add_widget (find_dlg, label_new (7, 3, labs[2]));
    add_widget (find_dlg, label_new (5, 3, labs[1]));
    add_widget (find_dlg, label_new (3, 3, labs[0]));

    dlg_select_widget (find_dlg, in_name);

    run_dlg (find_dlg);

    switch (find_dlg->ret_value) {
    case B_CANCEL:
	return_value = 0;
	break;

    case B_TREE:
	temp_dir = g_strdup (in_start->buffer);
	case_sensitive = case_sense->state & C_BOOL;
	destroy_dlg (find_dlg);
	g_free (in_start_dir);
	if (strcmp (temp_dir, ".") == 0) {
	    g_free (temp_dir);
	    temp_dir = g_strdup (current_panel->cwd);
	}
	in_start_dir = tree_box (temp_dir);
	if (in_start_dir)
	    g_free (temp_dir);
	else
	    in_start_dir = temp_dir;
	/* Warning: Dreadful goto */
	goto find_par_start;
	break;

    default:
	g_free (in_contents);
	if (in_with->buffer[0]) {
	    *content = g_strdup (in_with->buffer);
	    in_contents = g_strdup (*content);
	} else {
	    *content = in_contents = NULL;
	    r = 0;
	}

	case_sensitive = case_sense->state & C_BOOL;
	return_value = 1;
	*start_dir = g_strdup (in_start->buffer);
	*pattern = g_strdup (in_name->buffer);

	g_free (in_start_dir);
	in_start_dir = g_strdup (*start_dir);
	g_free (in_start_name);
	in_start_name = g_strdup (*pattern);
    }

    destroy_dlg (find_dlg);

    return return_value;
}