1
1

Viewer is nicer; Viewer is gnome-app; Viewer gets lots of options; Code gets cleaned -miguel

Этот коммит содержится в:
Miguel de Icaza 1998-03-14 00:42:23 +00:00
родитель 347f04ec92
Коммит ade5223b23
24 изменённых файлов: 306 добавлений и 79 удалений

Просмотреть файл

@ -1,3 +1,16 @@
Fri Mar 13 16:01:28 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gwidget.c (buttonbar_clicked, x_create_buttonbar): Button bar
widget implemented.
* gtools.c: Implement the non-modal version of the message
routine.
* gview.c: Create a GnomeApp widget to contain the viewer.
* gmain.c (xtoolkit_create_dialog): Add a new mode where the
container window is a GNOME_APP window.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gscreen.c (x_select_item): Make it use GTK_VISIBILITY_FULL

Просмотреть файл

@ -23,6 +23,9 @@
#define PORT_WANTS_VIEW 1
#define PORT_HAS_VIEW_FREEZE 1
#define PORT_HAS_SAVE_PANEL_TYPES 1
#define PORT_HAS_DESTROY_CMD 1
#define PORT_HAS_RADIO_FOCUS_ITEM 1
#define PORT_HAS_DIALOG_STOP 1
#define mi_getch() fprintf (stderr, "mi_getch is not implemented in this port\n")
#define frontend_run_dlg(x) gtkrundlg_event (x)

Просмотреть файл

@ -187,11 +187,15 @@ void configure_box (void);
GnomeUIInfo gnome_panel_file_menu [] = {
{ GNOME_APP_UI_ITEM, "Open Terminal", "Opens a terminal", gnome_open_terminal },
{ GNOME_APP_UI_SEPARATOR },
{ GNOME_APP_UI_ITEM, "Copy", "Copy files", copy_cmd },
{ GNOME_APP_UI_ITEM, "Rename/Move", "Rename or move files", ren_cmd },
{ GNOME_APP_UI_ITEM, "Mkdir", "Creates a new folder", mkdir_cmd },
{ GNOME_APP_UI_ITEM, "Delete", "Delete files from disk", delete_cmd },
{ GNOME_APP_UI_SEPARATOR },
{ GNOME_APP_UI_ITEM, "View", "View file", panel_action_view },
{ GNOME_APP_UI_ITEM, "View raw", "View the file without further processing",panel_action_view_unfiltered},
{ GNOME_APP_UI_SEPARATOR },
{ GNOME_APP_UI_ITEM, "Select group", "Selects a group of files", select_cmd },
{ GNOME_APP_UI_ITEM, "Unselect group", "Un-selects a group of marked files", select_cmd },
{ GNOME_APP_UI_ITEM, "Reverse selection", "Reverses the list of tagged files", reverse_selection_cmd },

Просмотреть файл

@ -32,11 +32,13 @@ char *default_edition_colors =
"selected=red:"
"viewunderline=brightred,blue:"
"directory=blue:"
"marked=white,seagreen:"
"markselect=red,yellow:"
"marked=yellow,seagreen:"
"execute=slateblue:"
"link=green:"
"device=magenta:"
"core=red:"
"menuhotsel=cyan,black:"
"special=black";
void
@ -139,7 +141,10 @@ xtoolkit_create_dialog (Dlg_head *h, int flags)
{
GtkWidget *win, *ted;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
if (flags & DLG_GNOME_APP)
win = gnome_app_new ("mc", h->name);
else
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
h->grided = flags;
h->idle_fn_tag = -1;
if (!(flags & DLG_NO_TED)){

Просмотреть файл

@ -300,13 +300,13 @@ panel_action_open_with (GtkWidget *widget, WPanel *panel)
free (command);
}
static void
void
panel_action_view (GtkWidget *widget, WPanel *panel)
{
view_cmd (panel);
}
static void
void
panel_action_view_unfiltered (GtkWidget *widget, WPanel *panel)
{
view_simple_cmd (panel);
@ -1000,13 +1000,13 @@ filter_item_select (GtkWidget *widget, gpointer data)
{
struct filter_item *fi = gtk_object_get_user_data (GTK_OBJECT (widget));
set_hintbar (easy_patterns ? fi->glob : fi->regexp);
/* set_hintbar (easy_patterns ? fi->glob : fi->regexp); */
}
static void
filter_item_deselect (GtkWidget *widget, gpointer data)
{
set_hintbar ("");
/* set_hintbar (""); */
}
static void

Просмотреть файл

@ -9,6 +9,9 @@ void x_add_sort_label (WPanel *panel, int index, char *text, char *tag, void *sr
void x_sort_label_start (WPanel *panel);
void x_reset_sort_labels (WPanel *panel);
void panel_action_view_unfiltered (GtkWidget *widget, WPanel *panel);
void panel_action_view (GtkWidget *widget, WPanel *panel);
WPanel *create_container (Dlg_head *h, char *str);
void panel_file_list_configure_contents (GtkWidget *file_list, WPanel *panel, int main_width, int height);

Просмотреть файл

@ -17,6 +17,7 @@
#include "dialog.h"
#include "color.h"
Dlg_head *last_query_dlg;
static int sel_pos;
void query_set_sel (int new_sel)
@ -44,7 +45,8 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
h = create_dlg (0, 0, 0, 0, dialog_colors, default_dlg_callback, "[QueryBox]", "query",
DLG_NO_TED);
dialog = GTK_DIALOG (gtk_dialog_new ());
h->wdata = dialog;
x_set_dialog_title (h, header);
label = label_new (0, 0, text, NULL);
@ -71,7 +73,8 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
/* Init the widgets */
init_dlg (h);
gtk_grab_add (GTK_WIDGET (dialog));
if (!(flags & D_INSERT))
gtk_grab_add (GTK_WIDGET (dialog));
/* Now do the GTK stuff */
gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (label->widget.wdata));
@ -82,11 +85,17 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
gtk_widget_show (GTK_WIDGET (dialog));
if (flags & D_INSERT){
last_query_dlg = h;
return 0;
}
frontend_run_dlg (h);
dlg_run_done (h);
last_query_dlg = h;
gtk_grab_remove (GTK_WIDGET (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
switch (h->ret_value){
case B_CANCEL:
break;
@ -114,10 +123,13 @@ Dlg_head *message (int error, char *header, char *text, ...)
va_end (args);
query_dialog (header, buffer, error, 1, "&Ok");
d = last_query_dlg;
/* FIXME: return what? */
return NULL;
if (error & D_INSERT){
x_flush_events ();
return d;
}
return d;
}
int

Просмотреть файл

@ -60,7 +60,7 @@ x_focus_view (WView *view)
}
void
view_percent (WView *view, int p, int w)
view_percent (WView *view, int p)
{
int percent;
char buffer [40];
@ -78,9 +78,9 @@ void
view_status (WView *view)
{
char buffer [80];
if (view->hex_mode)
sprintf (buffer, "Offset 0x$08x", view->edit_cursor);
sprintf (buffer, "Offset 0x%08x", view->edit_cursor);
else
sprintf (buffer, "Col %d", -view->start_col);
gtk_label_set (GTK_LABEL (view->gtk_offset), buffer);
@ -88,7 +88,10 @@ view_status (WView *view)
sprintf (buffer, "%s bytes", size_trunc (view->s.st_size));
gtk_label_set (GTK_LABEL (view->gtk_bytes), buffer);
gtk_label_set (GTK_LABEL (view->gtk_flags), view->growing_buffer ? "[grow]" : "");
if (view->hex_mode)
view_percent (view, view->edit_cursor - view->first);
else
view_percent (view, view->start_display - view->first);
}
void
@ -178,9 +181,13 @@ gview_status (WView *view)
s = gtk_hbox_new (0, 0);
view->gtk_fname = prepare_status (s);
view->gtk_offset = prepare_status (s);
view->gtk_bytes = prepare_status (s);
view->gtk_flags = prepare_status (s);
if (view->growing_buffer){
view->gtk_flags = prepare_status (s);
gtk_label_set (GTK_LABEL (view->gtk_flags), "[grow]");
}
view->gtk_percent = prepare_status (s);
gtk_label_set (GTK_LABEL (view->gtk_fname),
@ -191,6 +198,104 @@ gview_status (WView *view)
return s;
}
void
gview_quit (GtkWidget *widget, WView *view)
{
dlg_run_done (view->widget.parent);
destroy_dlg (view->widget.parent);
}
void
gnome_normal_search_cmd (GtkWidget *widget, WView *view)
{
normal_search_cmd (view);
}
void
gnome_regexp_search_cmd (GtkWidget *widget, WView *view)
{
regexp_search_cmd (view);
}
void
gnome_continue_search (GtkWidget *widget, WView *view)
{
continue_search (view);
}
void
gnome_goto_line (GtkWidget *widget, WView *view)
{
goto_line (view);
}
void
gnome_toggle_wrap (GtkWidget *widget, WView *view)
{
toggle_wrap_mode (view);
}
static void
gnome_toggle_parse (GtkWidget *widget, WView *view)
{
change_viewer (view);
}
static void
gnome_toggle_format (GtkWidget *widget, WView *view)
{
change_nroff (view);
}
static void
gnome_toggle_hex (GtkWidget *widget, WView *view)
{
toggle_hex_mode (view);
}
static void
gnome_monitor (GtkWidget *widget, WView *view)
{
set_monitor (view, 1);
}
GnomeUIInfo gview_file_menu [] = {
GNOMEUIINFO_ITEM ("Goto line", "Jump to a specified line number", &gnome_goto_line, NULL),
GNOMEUIINFO_ITEM ("Monitor file", "Monitor file growing", &gnome_monitor, NULL),
GNOMEUIINFO_ITEM ("Quit", "Terminate the viewer", &gview_quit, NULL),
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
GnomeUIInfo gview_search_menu [] = {
GNOMEUIINFO_ITEM ("Search", "String search", gnome_normal_search_cmd, NULL),
GNOMEUIINFO_ITEM ("Regexp search", "Regular expression search", gnome_regexp_search_cmd, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM ("Search again...", "Continue searching", gnome_continue_search, NULL),
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
GnomeUIInfo gview_mode_menu [] = {
#define WRAP_POS 0
GNOMEUIINFO_TOGGLEITEM ("Wrap", "Wrap the text", gnome_toggle_wrap, NULL),
#if 0
/* Can not use this one yet, as it destroys the viewer, need to fix that */
GNOMEUIINFO_TOGGLEITEM ("Parsed view", NULL, gnome_toggle_parse, NULL),
#endif
#define FORMAT_POS 1
GNOMEUIINFO_TOGGLEITEM ("Formatted", NULL, gnome_toggle_format, NULL),
#define HEX_POS 2
GNOMEUIINFO_TOGGLEITEM ("Hex", NULL, gnome_toggle_hex, NULL),
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
GnomeUIInfo gview_top_menu [] = {
{ GNOME_APP_UI_SUBTREE, "File", NULL, &gview_file_menu },
{ GNOME_APP_UI_SUBTREE, "Search", NULL, &gview_search_menu },
{ GNOME_APP_UI_SUBTREE, "Mode", NULL, &gview_mode_menu },
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
int
view (char *_command, char *_file, int *move_dir_p, int start_line)
{
@ -205,14 +310,14 @@ view (char *_command, char *_file, int *move_dir_p, int start_line)
our_dlg = create_dlg (0, 0, 0, 0, midnight_colors,
gnome_view_callback, "[Internal File Viewer]",
"view",
DLG_NO_TED);
DLG_NO_TED | DLG_GNOME_APP);
toplevel = GTK_WIDGET (our_dlg->wdata);
vbox = GTK_VBOX (gtk_vbox_new (0, 0));
gtk_window_set_policy (GTK_WINDOW (toplevel), TRUE, TRUE, TRUE);
gtk_container_add (GTK_CONTAINER (toplevel), GTK_WIDGET (vbox));
gnome_app_set_contents (GNOME_APP (toplevel), GTK_WIDGET (vbox));
gtk_window_set_title (GTK_WINDOW (toplevel),
_command ? _command : _file);
wview = view_new (0, 0, 80, 25, 0);
@ -231,8 +336,15 @@ view (char *_command, char *_file, int *move_dir_p, int start_line)
return !error;
status = gview_status (wview);
gnome_app_create_menus_with_data (GNOME_APP (toplevel), gview_top_menu, wview);
/* Setup the menus checkboxes correctly */
GTK_CHECK_MENU_ITEM (gview_mode_menu [WRAP_POS].widget)->active = wview->wrap_mode;
GTK_CHECK_MENU_ITEM (gview_mode_menu [FORMAT_POS].widget)->active = wview->viewer_nroff_flag;
GTK_CHECK_MENU_ITEM (gview_mode_menu [HEX_POS].widget)->active = wview->hex_mode;
init_dlg (our_dlg);
gtk_box_pack_start (GTK_BOX (vbox), status, 0, 1, 0);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (wview->widget.wdata), 1, 1, 0);
gtk_widget_show_all (toplevel);

Просмотреть файл

@ -27,6 +27,12 @@ get_gtk_widget (Widget_Item *p)
return (GTK_WIDGET (p->widget->wdata));
}
void
x_dialog_stop (Dlg_head *h)
{
gtk_main_quit ();
}
void
x_focus_widget (Widget_Item *p)
{
@ -65,9 +71,8 @@ gbutton_callback (GtkWidget *w, void *data)
stop = (*b->callback)(b->action, b->callback_data);
if (!b->callback || stop){
h->running = 0;
h->ret_value = b->action;
gtk_main_quit ();
dlg_stop (h);
}
}
@ -397,19 +402,57 @@ x_label_set_text (WLabel *label, char *text)
}
/* Buttonbar */
static void
buttonbar_clicked (GtkWidget *widget, WButtonBar *bb)
{
GtkBox *box = GTK_BOX (widget->parent);
GList *children = box->children;
int i;
/* Find out which button we are (number) */
for (i = 0; children; children = children->next, i++){
if (((GtkBoxChild *)children->data)->widget == widget){
if (bb->labels [i].function)
(*bb->labels [i].function)(bb->labels [i].data);
return;
}
}
printf ("Mhm, should not happen\n");
}
int
x_create_buttonbar (Dlg_head *h, widget_data parent, WButtonBar *bb)
{
GtkWidget *hbox;
int i;
hbox = gtk_hbox_new (0, 0);
for (i = 0; i < 10; i++){
char buffer [40];
GtkButton *b;
sprintf (buffer, "F%d %s", bb->labels [i].text ? bb->labels [i].text : " ");
b = gtk_button_new_with_label (buffer);
gtk_signal_connect (GTK_OBJECT (b), "clicked",
GTK_SIGNAL_FUNC (buttonbar_clicked), bb);
gtk_widget_show (b);
gtk_box_pack_start_defaults (GTK_BOX (hbox), b);
}
gtk_widget_show (hbox);
bb->widget.wdata = (widget_data) hbox;
}
void
x_redefine_label (WButtonBar *bb, int idx)
{
}
GtkBox *box = GTK_BOX (bb->widget.wdata);
GtkBoxChild *bc = (GtkBoxChild *)g_list_nth (box->children, idx)->data;
GtkButton *button = GTK_BUTTON (bc->widget);
GtkWidget *label = gtk_label_new (bb->labels [idx].text);
int
x_find_buttonbar_check (WButtonBar *bb, Widget *paneletc)
{
gtk_widget_show (label);
gtk_container_remove (GTK_CONTAINER (button), button->child);
gtk_container_add (GTK_CONTAINER (button), label);
}
/* Gauges */

Просмотреть файл

@ -1,4 +1,6 @@
Thu Mar 12 23:23:00 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
Fri Mar 13 18:10:58 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* dlg.c (dlg_stop): New routine used to finish dialog boxes.
* cmd.c (set_panel_filter_to): Implementation split. To be used
by GNOME.

Просмотреть файл

@ -244,8 +244,8 @@ static int chl_callback (Dlg_head * h, int Par, int Msg)
switch (Par) {
case KEY_LEFT:
case KEY_RIGHT:
h->running = 0;
h->ret_value = Par;
dlg_stop (h);
}
}
return 0;

Просмотреть файл

@ -146,20 +146,20 @@ static int display_callback (struct Dlg_head *h, int id, int Msg)
case DLG_KEY:
if (id == '\n'){
if((WRadio *) h->current->widget == my_radio){
h->running = 0;
assign_text (status, displays_status [my_radio->sel]);
dlg_stop (h);
break;
}
if ((WInput *) h->current->widget == user){
h->running = 0;
h->ret_value = B_USER + 6;
dlg_stop (h);
break;
}
if ((WInput *) h->current->widget == status){
h->running = 0;
h->ret_value = B_USER + 7;
dlg_stop (h);
break;
}
}
@ -437,8 +437,8 @@ static int tree_callback (struct Dlg_head *h, int id, int msg)
case DLG_POST_KEY:
/* The enter key will be processed by the tree widget */
if (id == '\n' || ((WTree *)(h->current->widget))->done){
h->running = 0;
h->ret_value = B_ENTER;
dlg_stop (h);
}
return MSG_HANDLED;

Просмотреть файл

@ -866,16 +866,16 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
switch (Par) {
case KEY_LEFT:
case KEY_RIGHT:
h->running = 0;
h->ret_value = 0;
dlg_stop (h);
return 1;
case 0177:
case KEY_BACKSPACE:
case XCTRL('h'):
if (end == min_end){
h->running = 0;
h->ret_value = 0;
dlg_stop (h);
return 1;
} else {
WLEntry *e, *e1;
@ -900,9 +900,9 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
if (is_in_input_map (input, Par) == 2){
if (end == min_end)
return 1;
h->running = 0;
h->ret_value = B_USER; /* This means we want to refill the
list box and start again */
dlg_stop (h);
return 1;
} else
return 0;
@ -941,8 +941,8 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
insert_text (input, last_text, low);
send_message (h, h->current->widget,WIDGET_DRAW,0);
} else if (need_redraw == 1){
h->running = 0;
h->ret_value = B_ENTER;
dlg_stop (h);
}
}
return 1;

Просмотреть файл

@ -54,6 +54,10 @@ Hook *idle_hook = 0;
# define x_set_idle(d,x)
#endif
#ifndef PORT_HAS_DIALOG_STOP
# define x_dialog_stop(d)
#endif
static void slow_box (Dlg_head *h, int y, int x, int ys, int xs)
{
move (h->y+y, h->x+x);
@ -511,6 +515,12 @@ void dlg_refresh (void *parameter)
dlg_redraw ((Dlg_head *) parameter);
}
void dlg_stop (Dlg_head *h)
{
h->running = 0;
x_dialog_stop (h);
}
static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
{
char *hlpfile;
@ -553,6 +563,7 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
case KEY_ENTER:
h->ret_value = B_ENTER;
h->running = 0;
x_dialog_stop (h);
break;
case ESC_CHAR:
@ -560,6 +571,7 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
case XCTRL ('c'):
case XCTRL ('g'):
h->running = 0;
x_dialog_stop (h);
h->ret_value = B_CANCEL;
break;
}

Просмотреть файл

@ -199,7 +199,8 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
char *help_ctx, char *name, int flags);
/* The flags: */
#define DLG_NO_TED 8 /* Gnome only: use a regular window, without ted */
#define DLG_GNOME_APP 16 /* GNOME only: use a gnome-app for the toplevel window */
#define DLG_NO_TED 8 /* GNOME only: do not manage layout with a GNOME GtkTed widget */
#define DLG_GRID 4 /* Widgets should be created under .widgets */
#define DLG_TRYUP 2 /* Try to move two lines up the dialog */
#define DLG_CENTER 1 /* Center the dialog */
@ -260,6 +261,7 @@ void widget_redraw (Dlg_head *h, Widget_Item *w);
int dlg_overlap (Widget *a, Widget *b);
void widget_erase (Widget *);
void dlg_erase (Dlg_head *h);
void dlg_stop (Dlg_head *h);
/* Widget selection */
int dlg_select_widget (struct Dlg_head *h, void *widget);

Просмотреть файл

@ -557,7 +557,7 @@ static void quit_cmd (void *x)
{
Dlg_head *h = (Dlg_head *) x;
h->running = 0;
dlg_stop (x);
}
static void prev_node_cmd (Dlg_head *h)
@ -699,7 +699,7 @@ static int help_handle_key (struct Dlg_head *h, int c)
case ESC_CHAR:
case XCTRL('g'):
h->running = 0;
dlg_stop (h);
break;
default:

Просмотреть файл

@ -433,7 +433,7 @@ static int hotlist_callback (Dlg_head * h, int Par, int Msg)
case KEY_RIGHT:
if (hotlist_button_callback (B_ENTER, 0)) {
h->ret_value = B_ENTER;
h->running = 0;
dlg_stop (h);
};
return 1;
break;
@ -455,7 +455,7 @@ l1:
char *tmp = copy_strings( "cd ", hlp->directory, NULL);
stuff (input_w (cmdline), tmp, 0);
free (tmp);
h->running = 0;
dlg_stop (h);
h->ret_value = B_CANCEL;
return 1;
}
@ -493,8 +493,8 @@ static int l_call (void *l)
if (list->current->data) {
struct hotlist *hlp = (struct hotlist*) list->current->data;
if (hlp->type == HL_TYPE_ENTRY) {
dlg->running = 0;
dlg->ret_value = B_ENTER;
dlg_stop (dlg);
return listbox_finish;
} else {
hotlist_button_callback (B_ENTER, (void *)0);
@ -502,8 +502,8 @@ static int l_call (void *l)
return listbox_nothing;
}
} else {
dlg->running = 0;
dlg->ret_value = B_ENTER;
dlg_stop (dlg);
return listbox_finish;
}
}

Просмотреть файл

@ -181,7 +181,7 @@ static int learn_check_key (int c)
Great! You have a complete terminal database!\n\
All your keys work well.");
}
learn_dlg->running = 0;
dlg_stop (learn_dlg);
}
return 1;
}

Просмотреть файл

@ -178,7 +178,7 @@ static struct {
{ "navigate_with_arrows", &navigate_with_arrows },
{ "advanced_chown", &advanced_chfns },
{ "drop_menus", &drop_menus },
{ "wrap_mode", &wrap_mode},
{ "wrap_mode", &global_wrap_mode},
{ "old_esc_mode", &old_esc_mode },
{ "cd_symlinks", &cd_symlinks },
{ "show_all_if_ambiguous", &show_all_if_ambiguous },

Просмотреть файл

@ -104,9 +104,6 @@ int max_dirt_limit =
static int view_callback (Dlg_head *h, WView *view, int msg, int par);
static void move_forward (WView *view, int i);
/* Wrap mode */
int wrap_mode = 1;
/* If set, show a ruler */
int ruler = 0;
@ -116,6 +113,9 @@ int mouse_move_pages_viewer = 1;
/* Used to compute the bottom first variable */
int have_fast_cpu = 0;
/* wrap mode default */
int global_wrap_mode = 1;
int default_hex_mode = 0;
int default_hexedit_mode = 0;
int default_magic_flag = 1;
@ -592,8 +592,6 @@ do_view_init (WView *view, char *_command, char *_file, int start_line)
if (!view->have_frame){
/* hex_mode = 0; */
/* wrap_mode = 1; */
view->start_col = 0;
}
if (_command && (view->viewer_magic_flag || _file[0] == '\0'))
@ -763,6 +761,12 @@ view_display_clean (WView *view, int height, int width)
# define view_thaw(view)
#endif
#ifdef HAVE_GNOME
# define PICK_COLOR(a,b) BOLD_COLOR : DEF_COLOR
#else
# define PICK_COLOR(a,b) a : b
#endif
/* Shows the file pointed to by *start_display on view_win */
static long
display (WView *view)
@ -873,7 +877,7 @@ display (WView *view)
view->cursor_col = col;
}
boldflag = 2;
view_set_color (view, view->view_side == view_side_left ? 15 : 31);
view_set_color (view, view->view_side == view_side_left ? PICK_COLOR (15, 31));
}
/* Print a hex number (sprintf is too slow) */
@ -919,7 +923,7 @@ display (WView *view)
view_set_color (view, BOLD_COLOR);
goto setcursor;
case 2:
view_set_color (view, view->view_side == view_side_left ? 31 : 15);
view_set_color (view, view->view_side == view_side_left ? PICK_COLOR (31, 15));
goto setcursor;
case 3:
view_set_color (view, 7);
@ -943,7 +947,7 @@ display (WView *view)
get_byte (view, from);
for (; row < height && from < view->last_byte; from++){
c = get_byte (view, from);
if ((c == '\n') || (col == width && wrap_mode)){
if ((c == '\n') || (col == width && view->wrap_mode)){
col = frame_shift;
row++;
if (c == '\n' || row >= height)
@ -1111,7 +1115,7 @@ move_forward2 (WView *view, long current, int lines, long upto)
c = get_byte (view, p);
if (wrap_mode){
if (view->wrap_mode){
if (c == '\r')
continue; /* This characters is never displayed */
else if (c == '\t')
@ -1188,7 +1192,7 @@ move_backward2 (WView *view, long current, int lines)
line = 0;
for (q = p = current - 1; p > view->first; p--)
if (get_byte (view, p) == '\n')
if (!wrap_mode){
if (!view->wrap_mode){
if (line == lines)
return p + 1;
line++;
@ -1287,7 +1291,7 @@ move_to_bottom (WView *view)
static void
move_right (WView *view)
{
if (wrap_mode && !view->hex_mode)
if (view->wrap_mode && !view->hex_mode)
return;
if (view->hex_mode) {
view->last = view->first + ((LINES-2) * view->bytes_per_line);
@ -1312,7 +1316,7 @@ move_right (WView *view)
static void
move_left (WView *view)
{
if (wrap_mode && !view->hex_mode)
if (view->wrap_mode && !view->hex_mode)
return;
if (view->hex_mode) {
if (view->hex_mode && view->view_side == view_side_left) {
@ -1780,9 +1784,9 @@ void toggle_wrap_mode (WView *view)
view_update (view);
return;
}
wrap_mode = 1 - wrap_mode;
view->wrap_mode = 1 - view->wrap_mode;
get_bottom_first (view, 1, 0);
if (wrap_mode)
if (view->wrap_mode)
view->start_col = 0;
else {
if (have_fast_cpu){
@ -1943,7 +1947,7 @@ change_viewer (WView *view)
}
}
static void
void
change_nroff (WView *view)
{
view->viewer_nroff_flag = !view->viewer_nroff_flag;
@ -1977,7 +1981,7 @@ view_labels (WView *view)
my_define (h, 2, view->hex_mode ? view->hexedit_mode ?
view->view_side == view_side_left ? "EdText" : "EdHex" :
view->growing_buffer ? "" : "Edit" :
wrap_mode ? "UnWrap" : "Wrap",
view->wrap_mode ? "UnWrap" : "Wrap",
toggle_wrap_mode, view);
my_define (h, 7, view->hex_mode ? "HxSrch" : "Search",
@ -2010,7 +2014,7 @@ check_left_right_keys (WView *view, int c)
enum { off, on };
static void
void
set_monitor (WView *view, int set_on)
{
int old = view->monitor;
@ -2027,6 +2031,17 @@ set_monitor (WView *view, int set_on)
}
}
void
continue_search (WView *view)
{
if (view->last_search){
(*view->last_search)(view, view->search_exp);
} else {
/* if not... then ask for an expression */
normal_search (view, 1);
}
}
/* Both views */
static int
view_handle_key (WView *view, int c)
@ -2104,12 +2119,7 @@ view_handle_key (WView *view, int c)
case XCTRL('s'):
case 'n':
case KEY_F(17):
if (view->last_search){
(*view->last_search)(view, view->search_exp);
} else {
/* if not... then ask for an expression */
normal_search (view, 1);
}
continue_search (view);
return 1;
case XCTRL('r'):
@ -2226,7 +2236,7 @@ view_event (WView *view, Gpm_Event *event, int *result)
{
*result = MOU_NORMAL;
if (event->type & (GPM_DOWN|GPM_DRAG)){
if (!wrap_mode){
if (!view->wrap_mode){
if (event->x < view->widget.cols / 4){
move_left (view);
*result = MOU_REPEAT;
@ -2433,7 +2443,7 @@ view_callback (Dlg_head *h, WView *v, int msg, int par)
case WIDGET_KEY:
i = view_handle_key ((WView *)view, par);
if (view->view_quit)
h->running = 0;
dlg_stop (h);
else {
view_update (view);
}
@ -2481,6 +2491,7 @@ view_new (int y, int x, int cols, int lines, int is_panel)
view->have_frame = is_panel;
view->last_byte = -1;
view->monitor = 0;
view->wrap_mode = global_wrap_mode;
x_init_view (view);

Просмотреть файл

@ -50,7 +50,8 @@ typedef struct {
struct hexedit_change_node *change_list; /* Linked list of changes */
int dirty; /* Number of skipped updates */
int wrap_mode; /* wrap_mode */
/* Mode variables */
int hex_mode; /* Hexadecimal mode flag */
int bytes_per_line; /* Number of bytes per line in hex mode */
@ -123,7 +124,9 @@ void toggle_hex_mode (WView *);
void goto_line (WView *);
void regexp_search_cmd (WView *);
void normal_search_cmd (WView *);
void continue_search (WView *);
void change_nroff (WView *view);
void set_monitor (WView *view, int set_on);
#endif
/* Command: view a file, if _command != NULL we use popen on _command */
@ -133,7 +136,7 @@ int view (char *_command, char *_file, int *move_direction, int start_line);
extern int mouse_move_pages_viewer;
extern int max_dirt_limit;
extern int wrap_mode;
extern int global_wrap_mode;
extern int have_fast_cpu;
extern int default_hex_mode;
extern int default_magic_flag;

Просмотреть файл

@ -58,11 +58,11 @@
# define x_redefine_label(a,b)
#endif
#ifndef HAVE_TK
#ifndef PORT_HAS_DESTROY_CMD
# define x_destroy_cmd(w)
#endif
#ifndef HAVE_GNOME
#ifndef PORT_HAS_RADIO_FOCUS_ITEM
# define x_radio_focus_item(r)
#endif
@ -96,8 +96,8 @@ button_callback (Dlg_head *h, WButton *b, int Msg, int Par)
if (b->callback)
stop = (*b->callback)(b->action, b->callback_data);
if (!b->callback || stop){
h->running = 0;
h->ret_value = b->action;
dlg_stop (h);
}
return 1;
@ -2121,8 +2121,8 @@ listbox_event (Gpm_Event *event, WListbox *l)
break;
case listbox_finish:
h->running = 0;
h->ret_value = B_ENTER;
dlg_stop (h);
return MOU_ENDLOOP;
case listbox_cback:

Просмотреть файл

@ -433,8 +433,8 @@ static int quick_callback (struct Dlg_head *h, int id, int Msg)
case DLG_KEY:
if (id == '\n'){
h->running = 0;
h->ret_value = B_ENTER;
dlg_stop (h);
break;
}
#endif

Просмотреть файл

@ -9,6 +9,8 @@
#define PORT_HAS_FILTER_CHANGED 1
#define PORT_HAS_PANEL_ADJUST_TOP_FILE 1
#define PORT_HAS_PANEL_RESET_SORT_LABELS 1
#define PORT_HAS_DESTROY_CMD 1
#define PORT_HAS_RADIO_FOCUS_ITEM 1
#define frontend_run_dlg(x) tkrundlg_event (x)