Beispiel #1
0
void
tty_draw_box (int y, int x, int ys, int xs, gboolean single)
{
    int y2, x2;

    if (ys <= 0 || xs <= 0)
        return;

    ys--;
    xs--;

    y2 = y + ys;
    x2 = x + xs;

    tty_draw_vline (y, x, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT], ys);
    tty_draw_vline (y, x2, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT], ys);
    tty_draw_hline (y, x, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ], xs);
    tty_draw_hline (y2, x, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ], xs);
    tty_gotoyx (y, x);
    tty_print_alt_char (ACS_ULCORNER, single);
    tty_gotoyx (y2, x);
    tty_print_alt_char (ACS_LLCORNER, single);
    tty_gotoyx (y, x2);
    tty_print_alt_char (ACS_URCORNER, single);
    tty_gotoyx (y2, x2);
    tty_print_alt_char (ACS_LRCORNER, single);
}
Beispiel #2
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);
        }
    }
}
Beispiel #3
0
Datei: menu.c Projekt: 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);
    }
}
Beispiel #4
0
Datei: hline.c Projekt: 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);
    }
}
Beispiel #5
0
extern void
tty_print_one_vline(void)
{
    if (slow_terminal)
	tty_print_char(' ');
    else
	tty_print_alt_char(ACS_VLINE);
}
Beispiel #6
0
Datei: tree.c Projekt: ryanlee/mc
static void
tree_frame (Dlg_head * h, WTree * tree)
{
    tty_setcolor (NORMAL_COLOR);
    widget_erase ((Widget *) tree);
    if (tree->is_panel)
    {
        const char *title = _("Directory tree");
        const int len = str_term_width1 (title);

        draw_box (h, tree->widget.y, tree->widget.x, tree->widget.lines, tree->widget.cols, FALSE);

        widget_move (&tree->widget, 0, (tree->widget.cols - len - 2) / 2);
        tty_printf (" %s ", title);

        if (panels_options.show_mini_info)
            widget_move (&tree->widget, tlines (tree) + 1, 0);
        tty_print_alt_char (ACS_LTEE, FALSE);
        widget_move (&tree->widget, tlines (tree) + 1, tree->widget.cols - 1);
        tty_print_alt_char (ACS_RTEE, FALSE);
        tty_draw_hline (tree->widget.y + tlines (tree) + 1,
                        tree->widget.x + 1, ACS_HLINE, tree->widget.cols - 2);
    }
}
Beispiel #7
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);
    }
}
Beispiel #8
0
void
rotate_dash (gboolean show)
{
    static const char rotating_dash[4] = "|/-\\";
    static size_t pos = 0;
    Widget *w = WIDGET (midnight_dlg);

    if (!nice_rotating_dash || (ok_to_refresh <= 0))
        return;

    widget_move (w, (menubar_visible != 0) ? 1 : 0, w->cols - 1);
    tty_setcolor (NORMAL_COLOR);

    if (!show)
        tty_print_alt_char (ACS_URCORNER, FALSE);
    else
    {
        tty_print_char (rotating_dash[pos]);
        pos = (pos + 1) % sizeof (rotating_dash);
    }

    mc_refresh ();
}
Beispiel #9
0
void
tty_print_one_vline (gboolean single)
{
    tty_print_alt_char (ACS_VLINE, single);
}
Beispiel #10
0
static cb_ret_t
hline_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WHLine *l = HLINE (w);
    WDialog *h = w->owner;

    switch (msg)
    {
    case MSG_INIT:
    case MSG_RESIZE:
        if (l->auto_adjust_cols)
        {
            Widget *wo = WIDGET (h);

            if (((h->flags & DLG_COMPACT) != 0))
            {
                w->x = wo->x;
                w->cols = wo->cols;
            }
            else
            {
                w->x = wo->x + 1;
                w->cols = wo->cols - 2;
            }
        }
        return MSG_HANDLED;

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

    case MSG_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);
        }

        if (l->text != NULL)
        {
            int text_width;

            text_width = str_term_width1 (l->text);
            widget_move (w, 0, (w->cols - text_width) / 2);
            tty_print_string (l->text);
        }
        return MSG_HANDLED;

    case MSG_DESTROY:
        g_free (l->text);
        return MSG_HANDLED;

    default:
        return widget_default_callback (w, sender, msg, parm, data);
    }
}