Add edit_info_status() function.

This commit is contained in:
Ilia Maslakov 2011-01-14 23:33:05 +00:00 committed by Andrew Borodin
parent 81f4c6a5ae
commit 2a62a7c792
3 changed files with 90 additions and 4 deletions

View File

@ -257,6 +257,7 @@ void edit_refresh_cmd (WEdit * edit);
void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);
int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
void edit_info_status (WEdit * edit);
void edit_status (WEdit * edit);
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
void edit_update_screen (WEdit * edit);

View File

@ -868,6 +868,89 @@ edit_status (WEdit * edit)
}
/* --------------------------------------------------------------------------------------------- */
void
edit_info_status (WEdit * edit)
{
int cols = edit->widget.cols;
tty_setcolor (STATUSBAR_COLOR);
if (cols > 5)
{
const char *fname = N_("NoName");
char *full_fname = NULL;
if (edit->filename_vpath != NULL)
{
full_fname = vfs_path_to_str (edit->filename_vpath);
fname = x_basename (full_fname);
}
#ifdef ENABLE_NLS
else
fname = _(fname);
#endif
edit_move (2, 0);
tty_printf ("[%s]", str_term_trim (fname, edit->widget.cols - 8 - 6));
g_free (full_fname);
}
if (cols > 13)
{
edit_move (edit->widget.cols - 8, 0);
tty_printf ("[%c%c%c%c]",
edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
edit->modified ? 'M' : '-',
macro_index < 0 ? '-' : 'R',
edit->overwrite == 0 ? '-' : 'O');
}
if (cols > 30)
{
edit_move (2, edit->widget.lines - 1);
tty_printf ("%3ld %5ld/%ld %6ld/%ld",
edit->curs_col + edit->over_col,
edit->curs_line + 1,
edit->total_lines + 1,
edit->curs1,
edit->last_byte );
}
/*
* If we are at the end of file, print <EOF>,
* otherwise print the current character as is (if printable),
* as decimal and as hex.
*/
if (cols > 46)
{
edit_move (32, edit->widget.lines - 1);
if (edit->curs1 >= edit->last_byte)
tty_print_string ("[<EOF> ]");
#ifdef HAVE_CHARSET
else if (edit->utf8)
{
unsigned int cur_utf;
int cw = 1;
cur_utf = edit_get_utf (edit, edit->curs1, &cw);
if (cw <= 0)
cur_utf = edit_get_byte (edit, edit->curs1);
tty_printf ("[%05d 0x%04X]", cur_utf, cur_utf);
}
#endif
else
{
unsigned char cur_byte;
cur_byte = edit_get_byte (edit, edit->curs1);
tty_printf ("[%05d 0x%04X]", (unsigned int) cur_byte, (unsigned int) cur_byte);
}
}
}
/* --------------------------------------------------------------------------------------------- */
/** this scrolls the text so that cursor is on the screen */
void
edit_scroll_screen_over_cursor (WEdit * edit)

View File

@ -440,14 +440,16 @@ edit_update_screen (WEdit * e)
edit_scroll_screen_over_cursor (e);
edit_update_curs_col (e);
/* draw a frame around edit area */
if (EDIT_WITH_FRAME)
if (!EDIT_WITH_FRAME)
edit_status (e);
else
{
/* draw a frame around edit area */
tty_setcolor (EDITOR_NORMAL_COLOR);
tty_draw_box (e->widget.y, e->widget.x, e->widget.lines, e->widget.cols, TRUE);
}
edit_status (e);
edit_info_status (e);
}
/* pop all events for this window for internal handling */
if (!is_idle ())