Ejemplo n.º 1
0
static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
{
    Dlg_head *h = tree->widget.parent;
    int      line;

    /* Show mini info */
    if (tree->is_panel){
	if (!show_mini_info)
	    return;
	line = tree_lines+2;
    } else
	line = tree_lines+1;

    tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols);
    widget_move (&tree->widget, line, 1);

    if (tree->searching){
	/* Show search string */
	tty_setcolor (TREE_NORMALC (h));
	tty_setcolor (DLG_FOCUSC (h));
	tty_print_char (PATH_SEP);

	tty_print_string (str_fit_to_term (tree->search_buffer, 
		tree_cols - 2, J_LEFT_FIT));
	tty_print_char (' ');
	tty_setcolor (DLG_FOCUSC (h));
    } else {
	/* Show full name of selected directory */
	tty_print_string (str_fit_to_term (tree->selected_ptr->name, 
		tree_cols, J_LEFT_FIT));
    }
}
Ejemplo n.º 2
0
static cb_ret_t
groupbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WGroupbox *g = GROUPBOX (w);

    switch (msg)
    {
    case MSG_DRAW:
        {
            WDialog *h = w->owner;

            gboolean disabled;

            disabled = widget_get_state (w, WST_DISABLED);
            tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]);
            tty_draw_box (w->y, w->x, w->lines, w->cols, TRUE);

            if (g->title != NULL)
            {
                tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_TITLE]);
                widget_move (w, 0, 1);
                tty_print_string (g->title);
            }
            return MSG_HANDLED;
        }

    case MSG_DESTROY:
        g_free (g->title);
        return MSG_HANDLED;

    default:
        return widget_default_callback (w, sender, msg, parm, data);
    }
}
Ejemplo n.º 3
0
Archivo: menu.c Proyecto: ryanlee/mc
static void
menubar_paint_idx (WMenuBar * menubar, unsigned int idx, int color)
{
    const Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
    const menu_entry_t *entry = g_list_nth_data (menu->entries, idx);
    const int y = 2 + idx;
    int x = menu->start_x;

    if (x + menu->max_entry_len + 4 > (gsize) menubar->widget.cols)
        x = menubar->widget.cols - menu->max_entry_len - 4;

    if (entry == NULL)
    {
        /* menu separator */
        tty_setcolor (MENU_ENTRY_COLOR);

        widget_move (&menubar->widget, y, x - 1);
        tty_print_alt_char (ACS_LTEE, FALSE);

        tty_draw_hline (menubar->widget.y + y, menubar->widget.x + x,
                        ACS_HLINE, menu->max_entry_len + 3);

        widget_move (&menubar->widget, y, x + menu->max_entry_len + 3);
        tty_print_alt_char (ACS_RTEE, FALSE);
    }
    else
    {
        int yt, xt;

        /* menu text */
        tty_setcolor (color);
        widget_move (&menubar->widget, y, x);
        tty_print_char ((unsigned char) entry->first_letter);
        tty_getyx (&yt, &xt);
        tty_draw_hline (yt, xt, ' ', menu->max_entry_len + 2);  /* clear line */
        tty_print_string (entry->text.start);

        if (entry->text.hotkey != NULL)
        {
            tty_setcolor (color == MENU_SELECTED_COLOR ? MENU_HOTSEL_COLOR : MENU_HOT_COLOR);
            tty_print_string (entry->text.hotkey);
            tty_setcolor (color);
        }

        if (entry->text.end != NULL)
            tty_print_string (entry->text.end);

        if (entry->shortcut != NULL)
        {
            widget_move (&menubar->widget, y, x + menu->max_hotkey_len + 3);
            tty_print_string (entry->shortcut);
        }

        /* move cursor to the start of entry text */
        widget_move (&menubar->widget, y, x + 1);
    }
}
Ejemplo n.º 4
0
static void
menubar_set_color (WMenuBar * menubar, gboolean current, gboolean hotkey)
{
    if (!menubar->is_active)
        tty_setcolor (MENU_INACTIVE_COLOR);
    else if (current)
        tty_setcolor (hotkey ? MENU_HOTSEL_COLOR : MENU_SELECTED_COLOR);
    else
        tty_setcolor (hotkey ? MENU_HOT_COLOR : MENU_ENTRY_COLOR);
}
Ejemplo n.º 5
0
static cb_ret_t
buttonbar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WButtonBar *bb = BUTTONBAR (w);
    int i;
    const char *text;

    switch (msg)
    {
    case MSG_FOCUS:
        return MSG_NOT_HANDLED;

    case MSG_HOTKEY:
        for (i = 0; i < BUTTONBAR_LABELS_NUM; i++)
            if (parm == KEY_F (i + 1) && buttonbar_call (bb, i))
                return MSG_HANDLED;
        return MSG_NOT_HANDLED;

    case MSG_DRAW:
        if (bb->visible)
        {
            buttonbar_init_button_positions (bb);
            widget_move (w, 0, 0);
            tty_setcolor (DEFAULT_COLOR);
            tty_printf ("%-*s", w->cols, "");
            widget_move (w, 0, 0);

            for (i = 0; i < BUTTONBAR_LABELS_NUM; i++)
            {
                int width;

                width = buttonbar_get_button_width (bb, i);
                if (width <= 0)
                    break;

                tty_setcolor (BUTTONBAR_HOTKEY_COLOR);
                tty_printf ("%2d", i + 1);

                tty_setcolor (BUTTONBAR_BUTTON_COLOR);
                text = (bb->labels[i].text != NULL) ? bb->labels[i].text : "";
                tty_print_string (str_fit_to_term (text, width - 2, J_LEFT_FIT));
            }
        }
        return MSG_HANDLED;

    case MSG_DESTROY:
        for (i = 0; i < BUTTONBAR_LABELS_NUM; i++)
            g_free (bb->labels[i].text);
        return MSG_HANDLED;

    default:
        return widget_default_callback (w, sender, msg, parm, data);
    }
}
Ejemplo n.º 6
0
Archivo: hline.c Proyecto: artzub/mc
static cb_ret_t
hline_callback (Widget * w, widget_msg_t msg, int parm)
{
    WHLine *l = (WHLine *) w;
    Dlg_head *h = l->widget.owner;

    switch (msg)
    {
    case WIDGET_INIT:
    case WIDGET_RESIZED:
        if (l->auto_adjust_cols)
        {
            if (((w->owner->flags & DLG_COMPACT) != 0))
            {
                w->x = w->owner->x;
                w->cols = w->owner->cols;
            }
            else
            {
                w->x = w->owner->x + 1;
                w->cols = w->owner->cols - 2;
            }
        }

    case WIDGET_FOCUS:
        /* We don't want to get the focus */
        return MSG_NOT_HANDLED;

    case WIDGET_DRAW:
        if (l->transparent)
            tty_setcolor (DEFAULT_COLOR);
        else
            tty_setcolor (h->color[DLG_COLOR_NORMAL]);

        tty_draw_hline (w->y, w->x + 1, ACS_HLINE, w->cols - 2);

        if (l->auto_adjust_cols)
        {
            widget_move (w, 0, 0);
            tty_print_alt_char (ACS_LTEE, FALSE);
            widget_move (w, 0, w->cols - 1);
            tty_print_alt_char (ACS_RTEE, FALSE);
        }
        return MSG_HANDLED;

    default:
        return default_proc (msg, parm);
    }
}
Ejemplo n.º 7
0
void
widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
{
    WDialog *h = w->owner;
    int color;

    if (widget_get_state (w, WST_DISABLED))
        color = DISABLED_COLOR;
    else if (hotkey)
    {
        if (focused)
            color = h->color[DLG_COLOR_HOT_FOCUS];
        else
            color = h->color[DLG_COLOR_HOT_NORMAL];
    }
    else
    {
        if (focused)
            color = h->color[DLG_COLOR_FOCUS];
        else
            color = h->color[DLG_COLOR_NORMAL];
    }

    tty_setcolor (color);
}
Ejemplo n.º 8
0
static void
view_status (WDiff *view, int ord, int width, int pos)
{
    char buf[BUFSIZ];
    int filename_width;
    off_t skip_offs = view->df[ord].offs;
    int moves = view->df[ord].move;

    tty_setcolor(SELECTED_COLOR);

#if VERTICAL_SPLIT
    tty_gotoyx(0, pos);
#else	/* !VERTICAL_SPLIT */
    tty_gotoyx(pos, 0);
#endif	/* !VERTICAL_SPLIT */

    filename_width = width - 22;
    if (filename_width < 8) {
	filename_width = 8;
    }
    if (filename_width >= (int)sizeof(buf)) {
	/* abnormal, but avoid buffer overflow */
	filename_width = sizeof(buf) - 1;
    }
    trim(strip_home_and_password(view->file[ord]), buf, filename_width);
    tty_printf("%-*s   %s%-16lX ", filename_width, buf, moves ? "0x" : "--", skip_offs);
}
Ejemplo n.º 9
0
static void chown_refresh (void)
{
    common_dialog_repaint (ch_dlg);

    tty_setcolor (COLOR_NORMAL);

    dlg_move (ch_dlg, BY - 1, 8);
    tty_print_string (_("owner"));
    dlg_move (ch_dlg, BY - 1, 16);
    tty_print_string (_("group"));
    dlg_move (ch_dlg, BY - 1, 24);
    tty_print_string (_("other"));
    
    dlg_move (ch_dlg, BY - 1, 35);
    tty_print_string (_("owner"));
    dlg_move (ch_dlg, BY - 1, 53);
    tty_print_string (_("group"));
    
    dlg_move (ch_dlg, 3, 4);
    tty_print_string (_("On"));
    dlg_move (ch_dlg, BY + 1, 4);
    tty_print_string (_("Flag"));
    dlg_move (ch_dlg, BY + 2, 4);
    tty_print_string (_("Mode"));

    if (!single_set){
	dlg_move (ch_dlg, 3, 54);
	tty_printf (_("%6d of %d"),
	    files_on_begin - (current_panel->marked) + 1,
	    files_on_begin);
    }

    print_flags ();
}
Ejemplo n.º 10
0
void
widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
{
    Dlg_head *h = w->owner;
    int color;

    if ((w->options & W_DISABLED) != 0)
        color = DISABLED_COLOR;
    else if (hotkey)
    {
        if (focused)
            color = h->color[DLG_COLOR_HOT_FOCUS];
        else
            color = h->color[DLG_COLOR_HOT_NORMAL];
    }
    else
    {
        if (focused)
            color = h->color[DLG_COLOR_FOCUS];
        else
            color = h->color[DLG_COLOR_NORMAL];
    }

    tty_setcolor (color);
}
Ejemplo n.º 11
0
static void print_flags (void)
{
    int i;

    tty_setcolor (COLOR_NORMAL);

    for (i = 0; i < 3; i++){
	dlg_move (ch_dlg, BY+1, 9+i);
	tty_print_char (ch_flags [i]);
    }
    
    for (i = 0; i < 3; i++){
	dlg_move (ch_dlg, BY + 1, 17 + i);
	tty_print_char (ch_flags [i+3]);
    }
    
    for (i = 0; i < 3; i++){
	dlg_move (ch_dlg, BY + 1, 25 + i);
	tty_print_char (ch_flags [i+6]);
    }

    update_permissions ();

    for (i = 0; i < 15; i++){
	dlg_move (ch_dlg, BY+1, 35+i);
	tty_print_char (ch_flags[9]);
    }
    for (i = 0; i < 15; i++){
	dlg_move (ch_dlg, BY + 1, 53 + i);
	tty_print_char (ch_flags[10]);
    }
}
Ejemplo n.º 12
0
Archivo: layout.c Proyecto: m32/mc
static void
update_split (const WDialog * h)
{
    /* Check split has to be done before testing if it changed, since
       it can change due to calling check_split() as well */
    check_split (&panels_layout);

    if (panels_layout.horizontal_split)
        check_options[0].widget->state = panels_layout.horizontal_equal ? 1 : 0;
    else
        check_options[0].widget->state = panels_layout.vertical_equal ? 1 : 0;
    widget_redraw (WIDGET (check_options[0].widget));

    tty_setcolor (check_options[0].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);

    widget_move (h, 6, 5);
    if (panels_layout.horizontal_split)
        tty_printf ("%03d", panels_layout.top_panel_size);
    else
        tty_printf ("%03d", panels_layout.left_panel_size);

    widget_move (h, 6, 17);
    if (panels_layout.horizontal_split)
        tty_printf ("%03d", height - panels_layout.top_panel_size);
    else
        tty_printf ("%03d", COLS - panels_layout.left_panel_size);

    widget_move (h, 6, 12);
    tty_print_char ('=');
}
Ejemplo n.º 13
0
static void
chmod_refresh (Dlg_head * h)
{
    common_dialog_repaint (h);

    tty_setcolor (COLOR_NORMAL);

    dlg_move (h, FY + 1, FX + 2);
    tty_print_string (_("Name"));
    dlg_move (h, FY + 3, FX + 2);
    tty_print_string (_("Permissions (Octal)"));
    dlg_move (h, FY + 5, FX + 2);
    tty_print_string (_("Owner name"));
    dlg_move (h, FY + 7, FX + 2);
    tty_print_string (_("Group name"));

    dlg_move (h, TY, TX);
    tty_print_string (_("Use SPACE to change"));
    dlg_move (h, TY + 1, TX);
    tty_print_string (_("an option, ARROW KEYS"));
    dlg_move (h, TY + 2, TX);
    tty_print_string (_("to move between options"));
    dlg_move (h, TY + 3, TX);
    tty_print_string (_("and T or INS to mark"));
}
Ejemplo n.º 14
0
static void
tree_frame (WDialog * h, WTree * tree)
{
    Widget *w = WIDGET (tree);

    (void) h;

    tty_setcolor (NORMAL_COLOR);
    widget_erase (w);
    if (tree->is_panel)
    {
        const char *title = _("Directory tree");
        const int len = str_term_width1 (title);

        tty_draw_box (w->y, w->x, w->lines, w->cols, FALSE);

        widget_move (w, 0, (w->cols - len - 2) / 2);
        tty_printf (" %s ", title);

        if (panels_options.show_mini_info)
        {
            int y;

            y = w->lines - 3;
            widget_move (w, y, 0);
            tty_print_alt_char (ACS_LTEE, FALSE);
            widget_move (w, y, w->cols - 1);
            tty_print_alt_char (ACS_RTEE, FALSE);
            tty_draw_hline (w->y + y, w->x + 1, ACS_HLINE, w->cols - 2);
        }
    }
}
Ejemplo n.º 15
0
static void update_mode (Dlg_head * h)
{
    print_flags ();
    tty_setcolor (COLOR_NORMAL);
    dlg_move (h, BY + 2, 9);
    tty_printf ("%12o", get_mode ());
    send_message (h->current, WIDGET_FOCUS, 0);
}
Ejemplo n.º 16
0
static inline void
edit_draw_frame (const WEdit * edit, int color, gboolean active)
{
    const Widget *w = (const Widget *) edit;

    /* draw a frame around edit area */
    tty_setcolor (color);
    /* draw double frame for active window if skin supports that */
    tty_draw_box (w->y, w->x, w->lines, w->cols, !active);
    /* draw a drag marker */
    if (edit->drag_state == MCEDIT_DRAG_NORMAL)
    {
        tty_setcolor (EDITOR_FRAME_DRAG);
        widget_move (w, w->lines - 1, w->cols - 1);
        tty_print_alt_char (ACS_LRCORNER, TRUE);
    }
}
Ejemplo n.º 17
0
Archivo: display.c Proyecto: artzub/mc
void
mcview_display_clean (mcview_t * view)
{
    tty_setcolor (NORMAL_COLOR);
    widget_erase ((Widget *) view);
    if (view->dpy_frame_size != 0)
        tty_draw_box (view->widget.y, view->widget.x, view->widget.lines, view->widget.cols, FALSE);
}
Ejemplo n.º 18
0
Archivo: chmod.c Proyecto: BrEacK/mc
static void
chmod_toggle_select (Dlg_head * h, int Id)
{
    tty_setcolor (COLOR_NORMAL);
    check_perm[Id].selected = !check_perm[Id].selected;

    dlg_move (h, PY + check_perm_num - Id, PX + 1);
    tty_print_char (check_perm[Id].selected ? '*' : ' ');
    dlg_move (h, PY + check_perm_num - Id, PX + 3);
}
Ejemplo n.º 19
0
void
mcview_display_clean (WView * view)
{
    Widget *w = WIDGET (view);

    tty_setcolor (VIEW_NORMAL_COLOR);
    widget_erase (w);
    if (view->dpy_frame_size != 0)
        tty_draw_box (w->y, w->x, w->lines, w->cols, FALSE);
}
Ejemplo n.º 20
0
static void
chmod_toggle_select (Dlg_head * h, int Id)
{
    tty_setcolor (COLOR_NORMAL);
    check_perm[Id].selected ^= 1;

    dlg_move (h, PY + PERMISSIONS - Id, PX + 1);
    tty_print_char ((check_perm[Id].selected) ? '*' : ' ');
    dlg_move (h, PY + PERMISSIONS - Id, PX + 3);
}
Ejemplo n.º 21
0
Archivo: dialog.c Proyecto: ryanlee/mc
/** Clean the dialog area, draw the frame and the title */
void
common_dialog_repaint (Dlg_head * h)
{
    int space;

    if (h->state != DLG_ACTIVE)
        return;

    space = (h->flags & DLG_COMPACT) ? 0 : 1;

    tty_setcolor (h->color[DLG_COLOR_NORMAL]);
    dlg_erase (h);
    draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space, FALSE);

    if (h->title != NULL)
    {
        tty_setcolor (h->color[DLG_COLOR_TITLE]);
        dlg_move (h, space, (h->cols - str_term_width1 (h->title)) / 2);
        tty_print_string (h->title);
    }
}
Ejemplo n.º 22
0
_START void tty_init(void)
{
	int i = 0;
	int j = 0;

	for (i = 0; i < TTY_MAX_ROW; i++){
		for (j = 0; j < TTY_MAX_COL; j++){
			tty_setcolor(i, j, clWhite, clBlack);
			tty_putchar(i, j, ' ');
		}
	}
}
Ejemplo n.º 23
0
static cb_ret_t
panelize_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    switch (msg)
    {
    case DLG_INIT:
    case DLG_POST_KEY:
        tty_setcolor (MENU_ENTRY_COLOR);
        update_command ();
        return MSG_HANDLED;

    case DLG_DRAW:
        common_dialog_repaint (h);
        tty_setcolor (COLOR_NORMAL);
        draw_box (h, UY, UX, h->lines - 10, h->cols - 10, TRUE);
        return MSG_HANDLED;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}
Ejemplo n.º 24
0
static cb_ret_t
groupbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WGroupbox *g = GROUPBOX (w);

    switch (msg)
    {
    case MSG_INIT:
        return MSG_HANDLED;

    case MSG_FOCUS:
        return MSG_NOT_HANDLED;

    case MSG_DRAW:
        {
            gboolean disabled;

            disabled = (w->options & W_DISABLED) != 0;
            tty_setcolor (disabled ? DISABLED_COLOR : COLOR_NORMAL);
            tty_draw_box (w->y, w->x, w->lines, w->cols, TRUE);

            if (g->title != NULL)
            {
                Widget *wo = WIDGET (w->owner);

                tty_setcolor (disabled ? DISABLED_COLOR : COLOR_TITLE);
                widget_move (wo, w->y - wo->y, w->x - wo->x + 1);
                tty_print_string (g->title);
            }
            return MSG_HANDLED;
        }

    case MSG_DESTROY:
        g_free (g->title);
        return MSG_HANDLED;

    default:
        return widget_default_callback (w, sender, msg, parm, data);
    }
}
Ejemplo n.º 25
0
Archivo: display.c Proyecto: artzub/mc
void
mcview_display_ruler (mcview_t * view)
{
    static const char ruler_chars[] = "|----*----";
    const screen_dimen top = view->ruler_area.top;
    const screen_dimen left = view->ruler_area.left;
    const screen_dimen width = view->ruler_area.width;
    const screen_dimen height = view->ruler_area.height;
    const screen_dimen line_row = (ruler == RULER_TOP) ? 0 : 1;
    const screen_dimen nums_row = (ruler == RULER_TOP) ? 1 : 0;

    char r_buff[10];
    off_t cl;
    screen_dimen c;

    if (ruler == RULER_NONE || height < 1)
        return;

    tty_setcolor (VIEW_BOLD_COLOR);
    for (c = 0; c < width; c++)
    {
        cl = view->dpy_text_column + c;
        if (line_row < height)
        {
            widget_move (view, top + line_row, left + c);
            tty_print_char (ruler_chars[cl % 10]);
        }

        if ((cl != 0) && (cl % 10) == 0)
        {
            g_snprintf (r_buff, sizeof (r_buff), "%" PRIuMAX, (uintmax_t) cl);
            if (nums_row < height)
            {
                widget_move (view, top + nums_row, left + c - 1);
                tty_print_string (r_buff);
            }
        }
    }
    tty_setcolor (NORMAL_COLOR);
}
Ejemplo n.º 26
0
Archivo: tree.c Proyecto: ryanlee/mc
static void
tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
{
    Dlg_head *h = tree->widget.owner;
    int line;

    /* Show mini info */
    if (tree->is_panel)
    {
        if (!panels_options.show_mini_info)
            return;
        line = tree_lines + 2;
    }
    else
        line = tree_lines + 1;

    if (tree->searching)
    {
        /* Show search string */
        tty_setcolor (INPUT_COLOR);
        tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols);
        widget_move (&tree->widget, line, 1);
        tty_print_char (PATH_SEP);
        tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT));
        tty_print_char (' ');
    }
    else
    {
        /* Show full name of selected directory */
        char *tmp_path;

        tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h));
        tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols);
        widget_move (&tree->widget, line, 1);
        tmp_path = vfs_path_to_str (tree->selected_ptr->name);
        tty_print_string (str_fit_to_term (tmp_path, tree_cols, J_LEFT_FIT));
        g_free (tmp_path);
    }
}
Ejemplo n.º 27
0
Archivo: groupbox.c Proyecto: artzub/mc
static cb_ret_t
groupbox_callback (Widget * w, widget_msg_t msg, int parm)
{
    WGroupbox *g = (WGroupbox *) w;

    switch (msg)
    {
    case WIDGET_INIT:
        return MSG_HANDLED;

    case WIDGET_FOCUS:
        return MSG_NOT_HANDLED;

    case WIDGET_DRAW:
        {
            gboolean disabled = (w->options & W_DISABLED) != 0;
            tty_setcolor (disabled ? DISABLED_COLOR : COLOR_NORMAL);
            draw_box (g->widget.owner, g->widget.y - g->widget.owner->y,
                      g->widget.x - g->widget.owner->x, g->widget.lines, g->widget.cols, TRUE);

            if (g->title != NULL)
            {
                tty_setcolor (disabled ? DISABLED_COLOR : COLOR_TITLE);
                dlg_move (g->widget.owner, g->widget.y - g->widget.owner->y,
                          g->widget.x - g->widget.owner->x + 1);
                tty_print_string (g->title);
            }
            return MSG_HANDLED;
        }

    case WIDGET_DESTROY:
        g_free (g->title);
        return MSG_HANDLED;

    default:
        return default_proc (msg, parm);
    }
}
Ejemplo n.º 28
0
static void
tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
{
    Widget *w = WIDGET (tree);
    int line;

    /* Show mini info */
    if (tree->is_panel)
    {
        if (!panels_options.show_mini_info)
            return;
        line = tree_lines + 2;
    }
    else
        line = tree_lines + 1;

    if (tree->searching)
    {
        /* Show search string */
        tty_setcolor (INPUT_COLOR);
        tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols);
        widget_move (w, line, 1);
        tty_print_char (PATH_SEP);
        tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT));
        tty_print_char (' ');
    }
    else
    {
        /* Show full name of selected directory */
        WDialog *h = w->owner;

        tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h));
        tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols);
        widget_move (w, line, 1);
        tty_print_string (str_fit_to_term
                          (vfs_path_as_str (tree->selected_ptr->name), tree_cols, J_LEFT_FIT));
    }
}
Ejemplo n.º 29
0
/** Clean the dialog area, draw the frame and the title */
void
dlg_default_repaint (WDialog * h)
{
    Widget *wh = WIDGET (h);

    int space;

    if (h->state != DLG_ACTIVE)
        return;

    space = (h->flags & DLG_COMPACT) ? 0 : 1;

    tty_setcolor (h->color[DLG_COLOR_NORMAL]);
    dlg_erase (h);
    tty_draw_box (wh->y + space, wh->x + space, wh->lines - 2 * space, wh->cols - 2 * space, FALSE);

    if (h->title != NULL)
    {
        tty_setcolor (h->color[DLG_COLOR_TITLE]);
        widget_move (h, space, (wh->cols - str_term_width1 (h->title)) / 2);
        tty_print_string (h->title);
    }
}
Ejemplo n.º 30
0
static cb_ret_t
edit_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    WEdit *edit;
    WMenuBar *menubar;
    WButtonBar *buttonbar;

    edit = (WEdit *) find_widget_type (h, edit_callback);
    menubar = find_menubar (h);
    buttonbar = find_buttonbar (h);

    switch (msg)
    {
    case DLG_INIT:
        edit_set_buttonbar (edit, buttonbar);
        return MSG_HANDLED;

    case DLG_DRAW:
        /* don't use common_dialog_repaint() -- we don't need a frame */
        tty_setcolor (EDITOR_NORMAL_COLOR);
        dlg_erase (h);
        return MSG_HANDLED;

    case DLG_RESIZE:
        /* dlg_set_size() is surplus for this case */
        h->lines = LINES;
        h->cols = COLS;
        widget_set_size (&buttonbar->widget, h->lines - 1, h->x, 1, h->cols);
        widget_set_size (&menubar->widget, h->y, h->x, 1, h->cols);
        menubar_arrange (menubar);
        widget_set_size (&edit->widget, h->y + 1, h->x, h->lines - 2, h->cols);
        return MSG_HANDLED;

    case DLG_ACTION:
        if (sender == (Widget *) menubar)
            return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
        if (sender == (Widget *) buttonbar)
            return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
        return MSG_HANDLED;

    case DLG_VALIDATE:
        h->state = DLG_ACTIVE;  /* don't stop the dialog before final decision */
        if (edit_ok_to_exit (edit))
            h->state = DLG_CLOSED;
        return MSG_HANDLED;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}