コード例 #1
0
ファイル: editdraw.c プロジェクト: ryanlee/mc
/** Draw the status line at the top of the screen. The size of the filename
 * field varies depending on the width of the screen and the length of
 * the filename. */
void
edit_status (WEdit * edit)
{
    const int w = edit->widget.owner->cols;
    const size_t status_size = w + 1;
    char *const status = g_malloc (status_size);
    int status_len;
    const char *fname = "";
    int fname_len;
    const int gap = 3;          /* between the filename and the status */
    const int right_gap = 5;    /* at the right end of the screen */
    const int preferred_fname_len = 16;

    status_string (edit, status, status_size);
    status_len = (int) str_term_width1 (status);

    if (edit->filename_vpath != NULL)
        fname = vfs_path_get_last_path_str (edit->filename_vpath);

    fname_len = str_term_width1 (fname);
    if (fname_len < preferred_fname_len)
        fname_len = preferred_fname_len;

    if (fname_len + gap + status_len + right_gap >= w)
    {
        if (preferred_fname_len + gap + status_len + right_gap >= w)
            fname_len = preferred_fname_len;
        else
            fname_len = w - (gap + status_len + right_gap);
        fname = str_trunc (fname, fname_len);
    }

    dlg_move (edit->widget.owner, 0, 0);
    tty_setcolor (STATUSBAR_COLOR);
    printwstr (fname, fname_len + gap);
    printwstr (status, w - (fname_len + gap));

    if (simple_statusbar && w > EDITOR_MINIMUM_TERMINAL_WIDTH)
    {
        size_t percent = 100;

        if (edit->total_lines + 1 != 0)
            percent = (edit->curs_line + 1) * 100 / (edit->total_lines + 1);
        dlg_move (edit->widget.owner, 0, w - 5);
        tty_printf (" %3d%%", percent);
    }

    g_free (status);
}
コード例 #2
0
ファイル: editdraw.c プロジェクト: ginggs/maemo-mc
static inline void
edit_status_fullscreen (WEdit * edit, int color)
{
    Widget *h = WIDGET (WIDGET (edit)->owner);
    const int w = h->cols;
    const size_t status_size = w + 1;
    char *const status = g_malloc (status_size);
    int status_len;
    const char *fname = "";
    int fname_len;
    const int gap = 3;          /* between the filename and the status */
    const int right_gap = 5;    /* at the right end of the screen */
    const int preferred_fname_len = 16;

    status_string (edit, status, status_size);
    status_len = (int) str_term_width1 (status);

    if (edit->filename_vpath != NULL)
        fname = vfs_path_get_last_path_str (edit->filename_vpath);

    fname_len = str_term_width1 (fname);
    if (fname_len < preferred_fname_len)
        fname_len = preferred_fname_len;

    if (fname_len + gap + status_len + right_gap >= w)
    {
        if (preferred_fname_len + gap + status_len + right_gap >= w)
            fname_len = preferred_fname_len;
        else
            fname_len = w - (gap + status_len + right_gap);
        fname = str_trunc (fname, fname_len);
    }

    widget_move (h, 0, 0);
    tty_setcolor (color);
    printwstr (fname, fname_len + gap);
    printwstr (status, w - (fname_len + gap));

    if (simple_statusbar && w > EDITOR_MINIMUM_TERMINAL_WIDTH)
    {
        int percent;

        percent = edit_buffer_calc_percent (&edit->buffer, edit->buffer.curs1);
        widget_move (h, 0, w - 6 - 6);
        tty_printf (" %3d%%", percent);
    }

    g_free (status);
}
コード例 #3
0
ファイル: editdraw.c プロジェクト: ebichu/dd-wrt
/* Draw the status line at the top of the widget. The size of the filename
 * field varies depending on the width of the screen and the length of
 * the filename. */
void
edit_status (WEdit *edit)
{
    const int w = edit->widget.cols;
    const size_t status_size = w + 1;
    char * const status = g_malloc (status_size);
    int status_len;
    const char *fname = "";
    int fname_len;
    const int gap = 3; /* between the filename and the status */
    const int right_gap = 2; /* at the right end of the screen */
    const int preferred_fname_len = 16;

    status_string (edit, status, status_size);
    status_len = (int) strlen (status);

    if (edit->filename)
        fname = edit->filename;
    fname_len = strlen(fname);
    if (fname_len < preferred_fname_len)
        fname_len = preferred_fname_len;

    if (fname_len + gap + status_len + right_gap >= w) {
	if (preferred_fname_len + gap + status_len + right_gap >= w)
	    fname_len = preferred_fname_len;
	else
            fname_len = w - (gap + status_len + right_gap);
	fname = name_trunc (fname, fname_len);
    }

    widget_move (edit, 0, 0);
    attrset (SELECTED_COLOR);
    printwstr (fname, fname_len + gap);
    printwstr (status, w - (fname_len + gap));
    attrset (EDITOR_NORMAL_COLOR);

    g_free (status);
}