static char * edit_get_title (const Dlg_head * h, size_t len) { const WEdit *edit = (const WEdit *) find_widget_type (h, edit_callback); const char *modified = edit->modified ? "(*) " : " "; const char *file_label; len -= 4; file_label = str_term_trim (edit->filename, len - str_term_width1 (_("Edit: "))); return g_strconcat (_("Edit: "), modified, file_label, (char *) NULL); }
static void edit_window_list (const Dlg_head * h) { const size_t offset = 2; /* skip menu and buttonbar */ const size_t dlg_num = g_list_length (h->widgets) - offset; int lines, cols; Listbox *listbox; GList *w; int i = 0; int rv; lines = min ((size_t) (LINES * 2 / 3), dlg_num); cols = COLS * 2 / 3; listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]"); for (w = h->widgets; w != NULL; w = g_list_next (w)) if (edit_widget_is_editor ((Widget *) w->data)) { WEdit *e = (WEdit *) w->data; char *fname; if (e->filename_vpath == NULL) fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName")); else { char *fname2; fname2 = vfs_path_to_str (e->filename_vpath); fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', fname2); g_free (fname2); } listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++), str_term_trim (fname, listbox->list->widget.cols - 2), NULL); g_free (fname); } rv = g_list_position (h->widgets, h->current) - offset; listbox_select_entry (listbox->list, rv); rv = run_listbox (listbox); if (rv >= 0) { w = g_list_nth (h->widgets, rv + offset); dlg_set_top_widget (w->data); } }
static char * edit_get_title (const Dlg_head * h, size_t len) { const WEdit *edit = find_editor (h); const char *modified = edit->modified ? "(*) " : " "; const char *file_label; char *filename; len -= 4; filename = vfs_path_to_str (edit->filename_vpath); if (filename == NULL) filename = g_strdup (_("[NoName]")); file_label = str_term_trim (filename, len - str_term_width1 (_("Edit: "))); g_free (filename); return g_strconcat (_("Edit: "), modified, file_label, (char *) NULL); }
char * mcview_get_title (const WDialog * h, size_t len) { const mcview_t *view = (const mcview_t *) find_widget_type (h, mcview_callback); const char *modified = view->hexedit_mode && (view->change_list != NULL) ? "(*) " : " "; const char *file_label; const char *view_filename; char *ret_str; view_filename = vfs_path_as_str (view->filename_vpath); len -= 4; file_label = view_filename != NULL ? view_filename : view->command != NULL ? view->command : ""; file_label = str_term_trim (file_label, len - str_term_width1 (_("View: "))); ret_str = g_strconcat (_("View: "), modified, file_label, (char *) NULL); return ret_str; }
static void edit_window_list (const WDialog * h) { const size_t dlg_num = g_list_length (h->widgets) - 2; /* 2 = skip menu and buttonbar */ int lines, cols; Listbox *listbox; GList *w; WEdit *selected; int i = 0; lines = MIN ((size_t) (LINES * 2 / 3), dlg_num); cols = COLS * 2 / 3; listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]"); for (w = h->widgets; w != NULL; w = g_list_next (w)) if (edit_widget_is_editor (CONST_WIDGET (w->data))) { WEdit *e = (WEdit *) w->data; char *fname; if (e->filename_vpath == NULL) fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName")); else fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', vfs_path_as_str (e->filename_vpath)); listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++), str_term_trim (fname, WIDGET (listbox->list)->cols - 2), e, FALSE); g_free (fname); } selected = run_listbox_with_data (listbox, h->current->data); if (selected != NULL) widget_select (WIDGET (selected)); }
static inline void edit_status_window (WEdit * edit) { int y, x; 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); } tty_getyx (&y, &x); x -= edit->widget.x; x += 4; if (x + 6 <= cols - 2 - 6) { edit_move (x, 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); } } }