static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols) { Dlg_head *h = tree->widget.parent; int line; /* Show mini info */ if (tree->is_panel){ if (!show_mini_info) return; line = tree_lines+2; } else line = tree_lines+1; tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols); widget_move (&tree->widget, line, 1); if (tree->searching){ /* Show search string */ tty_setcolor (TREE_NORMALC (h)); tty_setcolor (DLG_FOCUSC (h)); tty_print_char (PATH_SEP); tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT)); tty_print_char (' '); tty_setcolor (DLG_FOCUSC (h)); } else { /* Show full name of selected directory */ tty_print_string (str_fit_to_term (tree->selected_ptr->name, tree_cols, J_LEFT_FIT)); } }
static void mcview_display_status (WView * view) { const screen_dimen top = view->status_area.top; const screen_dimen left = view->status_area.left; const screen_dimen width = view->status_area.width; const screen_dimen height = view->status_area.height; const char *file_label; if (height < 1) return; tty_setcolor (STATUSBAR_COLOR); tty_draw_hline (WIDGET (view)->y + top, WIDGET (view)->x + left, ' ', width); file_label = view->filename_vpath != NULL ? vfs_path_get_last_path_str (view->filename_vpath) : view->command != NULL ? view->command : ""; if (width > 40) { widget_move (view, top, width - 32); if (view->hex_mode) tty_printf ("0x%08" PRIxMAX, (uintmax_t) view->hex_cursor); else { char buffer[BUF_TRUNC_LEN + 1]; size_trunc_len (buffer, BUF_TRUNC_LEN, mcview_get_filesize (view), 0, panels_options.kilobyte_si); tty_printf ("%9" PRIuMAX "/%s%s %s", (uintmax_t) view->dpy_end, buffer, mcview_may_still_grow (view) ? "+" : " ", #ifdef HAVE_CHARSET mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : #endif ""); } } widget_move (view, top, left); if (width > 40) tty_print_string (str_fit_to_term (file_label, width - 34, J_LEFT_FIT)); else tty_print_string (str_fit_to_term (file_label, width - 5, J_LEFT_FIT)); if (width > 26) mcview_display_percent (view, view->hex_mode ? view->hex_cursor : view->dpy_end); }
static int sel_skin_button (WButton * button, int action) { int result; WListbox *skin_list; WDialog *skin_dlg; const gchar *skin_name; int lxx, lyy; unsigned int i; unsigned int pos = 1; (void) action; lxx = COLS / 2; lyy = (LINES - 13) / 2; skin_dlg = dlg_create (TRUE, lyy, lxx, 13, 24, dialog_colors, NULL, NULL, "[Appearance]", _("Skins"), DLG_COMPACT); skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL); skin_name = "default"; listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name), (void *) skin_name); if (strcmp (skin_name, current_skin_name) == 0) listbox_select_entry (skin_list, 0); for (i = 0; i < skin_names->len; i++) { skin_name = g_ptr_array_index (skin_names, i); if (strcmp (skin_name, "default") != 0) { listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name), (void *) skin_name); if (strcmp (skin_name, current_skin_name) == 0) listbox_select_entry (skin_list, pos); pos++; } } add_widget (skin_dlg, skin_list); result = dlg_run (skin_dlg); if (result == B_ENTER) { Widget *w; gchar *skin_label; listbox_get_current (skin_list, &skin_label, (void **) &skin_name); g_free (current_skin_name); current_skin_name = g_strdup (skin_name); skin_apply (skin_name); w = dlg_find_by_id (WIDGET (button)->owner, skin_name_id); button_set_text (BUTTON (w), str_fit_to_term (skin_label, 20, J_LEFT_FIT)); } dlg_destroy (skin_dlg); return 0; }
static void mcview_display_status (mcview_t * view) { const screen_dimen top = view->status_area.top; const screen_dimen left = view->status_area.left; const screen_dimen width = view->status_area.width; const screen_dimen height = view->status_area.height; const char *file_label; screen_dimen file_label_width; if (height < 1) return; tty_setcolor (STATUSBAR_COLOR); widget_move (view, top, left); tty_draw_hline (-1, -1, ' ', width); file_label = view->filename ? view->filename : view->command ? view->command : ""; file_label_width = str_term_width1 (file_label) - 2; if (width > 40) { char buffer[BUF_TINY]; widget_move (view, top, width - 32); if (view->hex_mode) tty_printf ("0x%08" PRIxMAX, (uintmax_t) view->hex_cursor); else { size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si); tty_printf ("%9" PRIuMAX "/%s%s %s", (uintmax_t) view->dpy_end, buffer, mcview_may_still_grow (view) ? "+" : " ", #ifdef HAVE_CHARSET mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : "" #else "" #endif ); } } widget_move (view, top, left); if (width > 40) tty_print_string (str_fit_to_term (file_label, width - 34, J_LEFT_FIT)); else tty_print_string (str_fit_to_term (file_label, width - 5, J_LEFT_FIT)); if (width > 26) mcview_percent (view, view->hex_mode ? view->hex_cursor : view->dpy_end); }
static cb_ret_t buttonbar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WButtonBar *bb = BUTTONBAR (w); int i; const char *text; switch (msg) { case MSG_FOCUS: return MSG_NOT_HANDLED; case MSG_HOTKEY: for (i = 0; i < BUTTONBAR_LABELS_NUM; i++) if (parm == KEY_F (i + 1) && buttonbar_call (bb, i)) return MSG_HANDLED; return MSG_NOT_HANDLED; case MSG_DRAW: if (bb->visible) { buttonbar_init_button_positions (bb); widget_move (w, 0, 0); tty_setcolor (DEFAULT_COLOR); tty_printf ("%-*s", w->cols, ""); widget_move (w, 0, 0); for (i = 0; i < BUTTONBAR_LABELS_NUM; i++) { int width; width = buttonbar_get_button_width (bb, i); if (width <= 0) break; tty_setcolor (BUTTONBAR_HOTKEY_COLOR); tty_printf ("%2d", i + 1); tty_setcolor (BUTTONBAR_BUTTON_COLOR); text = (bb->labels[i].text != NULL) ? bb->labels[i].text : ""; tty_print_string (str_fit_to_term (text, width - 2, J_LEFT_FIT)); } } return MSG_HANDLED; case MSG_DESTROY: for (i = 0; i < BUTTONBAR_LABELS_NUM; i++) g_free (bb->labels[i].text); return MSG_HANDLED; default: return widget_default_callback (w, sender, msg, parm, data); } }
static void tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols) { Dlg_head *h = tree->widget.owner; int line; /* Show mini info */ if (tree->is_panel) { if (!panels_options.show_mini_info) return; line = tree_lines + 2; } else line = tree_lines + 1; if (tree->searching) { /* Show search string */ tty_setcolor (INPUT_COLOR); tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols); widget_move (&tree->widget, line, 1); tty_print_char (PATH_SEP); tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT)); tty_print_char (' '); } else { /* Show full name of selected directory */ char *tmp_path; tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h)); tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols); widget_move (&tree->widget, line, 1); tmp_path = vfs_path_to_str (tree->selected_ptr->name); tty_print_string (str_fit_to_term (tmp_path, tree_cols, J_LEFT_FIT)); g_free (tmp_path); } }
static void tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols) { Widget *w = WIDGET (tree); int line; /* Show mini info */ if (tree->is_panel) { if (!panels_options.show_mini_info) return; line = tree_lines + 2; } else line = tree_lines + 1; if (tree->searching) { /* Show search string */ tty_setcolor (INPUT_COLOR); tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols); widget_move (w, line, 1); tty_print_char (PATH_SEP); tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT)); tty_print_char (' '); } else { /* Show full name of selected directory */ WDialog *h = w->owner; tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h)); tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols); widget_move (w, line, 1); tty_print_string (str_fit_to_term (vfs_path_as_str (tree->selected_ptr->name), tree_cols, J_LEFT_FIT)); } }
static void chown_info_update (void) { /* display file info */ tty_setcolor (COLOR_NORMAL); /* name && mode */ dlg_move (ch_dlg, 3, 8); tty_print_string (str_fit_to_term (fname, 45, J_LEFT_FIT)); dlg_move (ch_dlg, BY + 2, 9); tty_printf ("%12o", get_mode ()); /* permissions */ update_permissions (); }
void appearance_box (void) { current_skin_name = g_strdup (mc_skin__default.name); skin_names = mc_skin_list (); { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_START_COLUMNS, QUICK_LABEL (N_("Skin:"), NULL), QUICK_NEXT_COLUMN, QUICK_BUTTON (str_fit_to_term (skin_name_to_label (current_skin_name), 20, J_LEFT_FIT), B_USER, sel_skin_button, NULL), QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 54, N_("Appearance"), "[Appearance]", quick_widgets, dlg_default_callback, NULL }; if (quick_dialog (&qdlg) == B_ENTER) mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, "skin", current_skin_name); else skin_apply (NULL); } g_free (current_skin_name); g_ptr_array_foreach (skin_names, (GFunc) g_free, NULL); g_ptr_array_free (skin_names, TRUE); }
static void listbox_draw (WListbox * l, gboolean focused) { Widget *w = WIDGET (l); const WDialog *h = w->owner; const gboolean disabled = (w->options & W_DISABLED) != 0; const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]; /* *INDENT-OFF* */ int selc = disabled ? DISABLED_COLOR : focused ? h->color[DLG_COLOR_HOT_FOCUS] : h->color[DLG_COLOR_FOCUS]; /* *INDENT-ON* */ int length = 0; GList *le = NULL; int pos; int i; int sel_line = -1; if (l->list != NULL) { length = g_queue_get_length (l->list); le = g_queue_peek_nth_link (l->list, (guint) l->top); } /* pos = (le == NULL) ? 0 : g_list_position (l->list, le); */ pos = (le == NULL) ? 0 : l->top; for (i = 0; i < w->lines; i++) { const char *text = ""; /* Display the entry */ if (pos == l->pos && sel_line == -1) { sel_line = i; tty_setcolor (selc); } else tty_setcolor (normalc); widget_move (l, i, 1); if (l->list != NULL && le != NULL && (i == 0 || pos < length)) { WLEntry *e = LENTRY (le->data); text = e->text; le = g_list_next (le); pos++; } tty_print_string (str_fit_to_term (text, w->cols - 2, J_LEFT_FIT)); } l->cursor_y = sel_line; if (l->scrollbar && length > w->lines) { tty_setcolor (normalc); listbox_drawscroll (l); } }
void chown_advanced_cmd (void) { /* Number of files at startup */ int files_on_begin; files_on_begin = MAX (1, current_panel->marked); do { /* do while any files remaining */ int file_idx; char buffer[BUF_MEDIUM]; vfs_path_t *vpath; int result; init_chown_advanced (); if (current_panel->marked) fname = next_file (); /* next marked file */ else fname = selection (current_panel)->fname; /* single file */ vpath = vfs_path_from_str (fname); if (mc_stat (vpath, sf_stat) != 0) { /* get status of file */ dlg_destroy (ch_dlg); vfs_path_free (vpath); break; } ch_cmode = sf_stat->st_mode; file_idx = files_on_begin == 1 ? 1 : (files_on_begin - current_panel->marked + 1); g_snprintf (buffer, sizeof (buffer), "%s (%d/%d)", str_fit_to_term (fname, WIDGET (ch_dlg)->cols - 20, J_LEFT_FIT), file_idx, files_on_begin); label_set_text (l_filename, buffer); chown_refresh (); update_ownership (); result = dlg_run (ch_dlg); switch (result) { case B_CANCEL: end_chown = TRUE; break; case B_ENTER: need_update = TRUE; if (mc_chmod (vpath, get_mode ()) == -1) message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"), fname, unix_error_string (errno)); /* call mc_chown only, if mc_chmod didn't fail */ else if (mc_chown (vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) (-1), (ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) (-1)) == -1) message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname, unix_error_string (errno)); break; case B_SETALL: apply_advanced_chowns (sf_stat); break; case B_SKIP: default: break; } if (current_panel->marked && result != B_CANCEL) { do_file_mark (current_panel, current_file, 0); need_update = TRUE; } dlg_destroy (ch_dlg); vfs_path_free (vpath); } while (current_panel->marked && !end_chown); chown_advanced_done (); }
static void show_tree (WTree * tree) { Widget *w = WIDGET (tree); WDialog *h = w->owner; tree_entry *current; int i, j, topsublevel; int x = 0, y = 0; int tree_lines, tree_cols; /* Initialize */ tree_lines = tlines (tree); tree_cols = w->cols; widget_move (w, y, x); if (tree->is_panel) { tree_cols -= 2; x = y = 1; } g_free (tree->tree_shown); tree->tree_shown = g_new0 (tree_entry *, tree_lines); if (tree->store->tree_first) topsublevel = tree->store->tree_first->sublevel; else topsublevel = 0; if (!tree->selected_ptr) { tree->selected_ptr = tree->store->tree_first; tree->topdiff = 0; } current = tree->selected_ptr; /* Calculate the directory which is to be shown on the topmost line */ if (!tree_navigation_flag) current = back_ptr (current, &tree->topdiff); else { i = 0; while (current->prev && i < tree->topdiff) { current = current->prev; if (current->sublevel < tree->selected_ptr->sublevel) { if (vfs_path_equal (current->name, tree->selected_ptr->name)) i++; } else if (current->sublevel == tree->selected_ptr->sublevel) { const char *cname; cname = vfs_path_as_str (current->name); for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--) ; if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) i++; } else if (current->sublevel == tree->selected_ptr->sublevel + 1) { j = vfs_path_len (tree->selected_ptr->name); if (j > 1 && vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) i++; } } tree->topdiff = i; } /* Loop for every line */ for (i = 0; i < tree_lines; i++) { tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h)); /* Move to the beginning of the line */ tty_draw_hline (w->y + y + i, w->x + x, ' ', tree_cols); if (current == NULL) continue; if (tree->is_panel) tty_setcolor (widget_get_state (w, WST_FOCUSED) && current == tree->selected_ptr ? SELECTED_COLOR : NORMAL_COLOR); else tty_setcolor (current == tree->selected_ptr ? TREE_CURRENTC (h) : TREE_NORMALC (h)); tree->tree_shown[i] = current; if (current->sublevel == topsublevel) /* Show full name */ tty_print_string (str_fit_to_term (vfs_path_as_str (current->name), tree_cols + (tree->is_panel ? 0 : 1), J_LEFT_FIT)); else { /* Sub level directory */ tty_set_alt_charset (TRUE); /* Output branch parts */ for (j = 0; j < current->sublevel - topsublevel - 1; j++) { if (tree_cols - 8 - 3 * j < 9) break; tty_print_char (' '); if (current->submask & (1 << (j + topsublevel + 1))) tty_print_char (ACS_VLINE); else tty_print_char (' '); tty_print_char (' '); } tty_print_char (' '); j++; if (!current->next || !(current->next->submask & (1 << current->sublevel))) tty_print_char (ACS_LLCORNER); else tty_print_char (ACS_LTEE); tty_print_char (ACS_HLINE); tty_set_alt_charset (FALSE); /* Show sub-name */ tty_print_char (' '); tty_print_string (str_fit_to_term (current->subname, tree_cols - x - 3 * j, J_LEFT_FIT)); } /* Calculate the next value for current */ current = current->next; if (tree_navigation_flag) { while (current != NULL) { if (current->sublevel < tree->selected_ptr->sublevel) { if (vfs_path_equal_len (current->name, tree->selected_ptr->name, vfs_path_len (current->name))) break; } else if (current->sublevel == tree->selected_ptr->sublevel) { const char *cname; cname = vfs_path_as_str (current->name); for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--) ; if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) break; } else if (current->sublevel == tree->selected_ptr->sublevel + 1 && vfs_path_len (tree->selected_ptr->name) > 1) { if (vfs_path_equal_len (current->name, tree->selected_ptr->name, vfs_path_len (tree->selected_ptr->name))) break; } current = current->next; } } } tree_show_mini_info (tree, tree_lines, tree_cols); }
int editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text, int xpos, int ypos) { /* dialog sizes */ int dlg_height = 9; int dlg_width = 8; int retval; int i; int btn_pos; char *repl_from, *repl_to; char tmp [BUF_MEDIUM]; QuickWidget quick_widgets[] = { /* 0 */ QUICK_BUTTON (44, dlg_width, 6, dlg_height, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (29, dlg_width, 6, dlg_height, N_("&Skip"), B_SKIP_REPLACE, NULL), /* 2 */ QUICK_BUTTON (21, dlg_width, 6, dlg_height, N_("A&ll"), B_REPLACE_ALL, NULL), /* 3 */ QUICK_BUTTON ( 4, dlg_width, 6, dlg_height, N_("&Replace"), B_ENTER, NULL), /* 4 */ QUICK_LABEL ( 3, dlg_width, 2, dlg_height, NULL), /* 5 */ QUICK_LABEL ( 2, dlg_width, 3, dlg_height, N_(" Replace with: ")), /* 6 */ QUICK_LABEL ( 3, dlg_width, 4, dlg_height, NULL), QUICK_END }; #ifdef ENABLE_NLS for (i = 0; i < 4; i++) quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); #endif /* calculate button positions */ btn_pos = 4; for (i = 3; i > -1; i--) { quick_widgets[i].relative_x = btn_pos; btn_pos += str_term_width1 (quick_widgets[i].u.button.text) + 5; if (i == 3) /* default button */ btn_pos += 2; } dlg_width = btn_pos + 2; /* correct widget coordinates */ for (i = 0; i < 7; i++) quick_widgets[i].x_divisions = dlg_width; g_snprintf (tmp, sizeof (tmp), " '%s'", from_text); repl_from = g_strdup (str_fit_to_term (tmp, dlg_width - 7, J_LEFT)); g_snprintf (tmp, sizeof (tmp), " '%s'", to_text); repl_to = g_strdup (str_fit_to_term (tmp, dlg_width - 7, J_LEFT)); quick_widgets[4].u.label.text = repl_from; quick_widgets[6].u.label.text = repl_to; if (xpos == -1) xpos = (edit->num_widget_columns - dlg_width) / 2; if (ypos == -1) ypos = edit->num_widget_lines * 2 / 3; { QuickDialog Quick_input = { dlg_width, dlg_height, 0, 0, N_ (" Confirm replace "), "[Input Line Keys]", quick_widgets, FALSE }; /* Sometimes menu can hide replaced text. I don't like it */ if ((edit->curs_row >= ypos - 1) && (edit->curs_row <= ypos + dlg_height - 1)) ypos -= dlg_height; Quick_input.ypos = ypos; Quick_input.xpos = xpos; retval = quick_dialog (&Quick_input); g_free (repl_from); g_free (repl_to); return retval; } }
static void show_tree (WTree *tree) { Dlg_head *h = tree->widget.parent; tree_entry *current; int i, j, topsublevel; int x, y; int tree_lines, tree_cols; /* Initialize */ x = y = 0; tree_lines = tlines (tree); tree_cols = tree->widget.cols; tty_setcolor (TREE_NORMALC (h)); widget_move ((Widget*)tree, y, x); if (tree->is_panel){ tree_cols -= 2; x = y = 1; } g_free (tree->tree_shown); tree->tree_shown = g_new (tree_entry*, tree_lines); for (i = 0; i < tree_lines; i++) tree->tree_shown [i] = NULL; if (tree->store->tree_first) topsublevel = tree->store->tree_first->sublevel; else topsublevel = 0; if (!tree->selected_ptr){ tree->selected_ptr = tree->store->tree_first; tree->topdiff = 0; } current = tree->selected_ptr; /* Calculate the directory which is to be shown on the topmost line */ if (tree_navigation_flag){ i = 0; while (current->prev && i < tree->topdiff){ current = current->prev; if (current->sublevel < tree->selected_ptr->sublevel){ if (strncmp (current->name, tree->selected_ptr->name, strlen (current->name)) == 0) i++; } else if (current->sublevel == tree->selected_ptr->sublevel){ for (j = strlen (current->name) - 1; current->name [j] != PATH_SEP; j--); if (strncmp (current->name, tree->selected_ptr->name, j) == 0) i++; } else if (current->sublevel == tree->selected_ptr->sublevel + 1 && strlen (tree->selected_ptr->name) > 1){ if (strncmp (current->name, tree->selected_ptr->name, strlen (tree->selected_ptr->name)) == 0) i++; } } tree->topdiff = i; } else current = back_ptr (current, &tree->topdiff); /* Loop for every line */ for (i = 0; i < tree_lines; i++){ /* Move to the beginning of the line */ tty_draw_hline (tree->widget.y + y + i, tree->widget.x + x, ' ', tree_cols); if (!current) continue; tree->tree_shown [i] = current; if (current->sublevel == topsublevel){ /* Top level directory */ if (tree->active && current == tree->selected_ptr) { if (!tty_use_colors () && !tree->is_panel) tty_setcolor (MARKED_COLOR); else tty_setcolor (SELECTED_COLOR); } /* Show full name */ tty_print_string (str_fit_to_term (current->name, tree_cols - 6, J_LEFT_FIT)); } else{ /* Sub level directory */ tty_set_alt_charset (TRUE); /* Output branch parts */ for (j = 0; j < current->sublevel - topsublevel - 1; j++){ if (tree_cols - 8 - 3 * j < 9) break; tty_print_char (' '); if (current->submask & (1 << (j + topsublevel + 1))) tty_print_char (ACS_VLINE); else tty_print_char (' '); tty_print_char (' '); } tty_print_char (' '); j++; if (!current->next || !(current->next->submask & (1 << current->sublevel))) tty_print_char (ACS_LLCORNER); else tty_print_char (ACS_LTEE); tty_print_char (ACS_HLINE); tty_set_alt_charset (FALSE); if (tree->active && current == tree->selected_ptr) { /* Selected directory -> change color */ if (!tty_use_colors () && !tree->is_panel) tty_setcolor (MARKED_COLOR); else tty_setcolor (SELECTED_COLOR); } /* Show sub-name */ tty_print_char (' '); tty_print_string (str_fit_to_term (current->subname, tree_cols - 2 - 4 - 3 * j, J_LEFT_FIT)); } tty_print_char (' '); /* Return to normal color */ tty_setcolor (TREE_NORMALC (h)); /* Calculate the next value for current */ current = current->next; if (tree_navigation_flag){ while (current){ if (current->sublevel < tree->selected_ptr->sublevel){ if (strncmp (current->name, tree->selected_ptr->name, strlen (current->name)) == 0) break; } else if (current->sublevel == tree->selected_ptr->sublevel){ for (j = strlen (current->name) - 1; current->name [j] != PATH_SEP; j--); if (strncmp (current->name,tree->selected_ptr->name,j)== 0) break; } else if (current->sublevel == tree->selected_ptr->sublevel+1 && strlen (tree->selected_ptr->name) > 1){ if (strncmp (current->name, tree->selected_ptr->name, strlen (tree->selected_ptr->name)) == 0) break; } current = current->next; } } } tree_show_mini_info (tree, tree_lines, tree_cols); }
static cb_ret_t label_callback (Widget * w, widget_msg_t msg, int parm) { WLabel *l = (WLabel *) w; Dlg_head *h = l->widget.owner; switch (msg) { case WIDGET_INIT: return MSG_HANDLED; /* We don't want to get the focus */ case WIDGET_FOCUS: return MSG_NOT_HANDLED; case WIDGET_DRAW: { char *p = l->text; int y = 0; gboolean disabled = (w->options & W_DISABLED) != 0; if (l->text == NULL) return MSG_HANDLED; if (l->transparent) tty_setcolor (disabled ? DISABLED_COLOR : DEFAULT_COLOR); else tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]); while (TRUE) { char *q; char c = '\0'; q = strchr (p, '\n'); if (q != NULL) { c = q[0]; q[0] = '\0'; } widget_move (&l->widget, y, 0); tty_print_string (str_fit_to_term (p, l->widget.cols, J_LEFT)); if (q == NULL) break; q[0] = c; p = q + 1; y++; } return MSG_HANDLED; } case WIDGET_DESTROY: g_free (l->text); return MSG_HANDLED; default: return default_proc (msg, parm); } }