diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index be5943f25..f62820ee2 100644 --- a/src/editor/edit-impl.h +++ b/src/editor/edit-impl.h @@ -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); diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c index 00477d6ea..0ed019a66 100644 --- a/src/editor/editdraw.c +++ b/src/editor/editdraw.c @@ -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 , + * 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 ("[ ]"); +#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) diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index c70238954..b4e0d19bf 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -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 ())