Added Viewer commands and shortcuts.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-11-07 13:46:05 +03:00
parent 8224a26cf4
commit e85f6b23e3
9 changed files with 332 additions and 237 deletions

View File

@ -158,7 +158,14 @@ EditLoadNextFile = alt-plus
SelectCodepage = alt-e
[viewer]
ViewSearch = question; slash; f7
ViewHelp = f1
ViewToggleWrapMode = f2
ViewQuit = f3; f10; q; esc; ctrl-g
ViewToggleHexMode = f4
ViewGoto = f5
ViewSearch = f7; question; slash
ViewToggleMagicMode = f8
ViewToggleNroffMode = f9
ViewContinueSearch = ctrl-r; ctrl-s; f17; n
ViewMoveToBol = ctrl-a
ViewMoveToEol = ctrl-e
@ -174,13 +181,21 @@ ViewGotoBookmark = m
ViewNewBookmark = r
ViewNextFile = ctrl-f
ViewPrevFile = ctrl-b
ViewQuit = q; esc; ctrl-g
SelectCodepage = alt-e
ShowCommandLine = ctrl-o
ViewToggleRuler = alt-r
[viewer:hex]
HexViewToggleNavigationMode = tab
ViewHelp = f1
ViewToggleHexEditMode = f2
ViewQuit = f3; f10; q; esc; ctrl-g
ViewToggleHexMode = f4
ViewGoto = f5
ViewHexEditSave = f6
ViewSearch = f7; question; slash
ViewToggleMagicMode = f8
ViewToggleNroffMode = f9
ViewToggleHexNavMode = tab
ViewMoveToBol = ctrl-a; home
ViewMoveToEol = ctrl-e; end
ViewMoveLeft = b; left
@ -281,7 +296,6 @@ PanelSortOrderByExt=
PanelSortOrderBySize=
PanelSortOrderByMTime=
[panel:xmap]
[input]

View File

@ -162,14 +162,22 @@ EditNew = k
EditExecuteMacro = e
[viewer]
ViewSearch = question; slash; f7
ViewHelp = f1
ViewToggleWrapMode = f2
ViewQuit = f3; f10; q; esc; ctrl-g
ViewToggleHexMode = f4
ViewGoto = f5
ViewSearch = f7; question; slash
ViewToggleMagicMode = f8
ViewToggleNroffMode = f9
ViewQuit = f3; f10; q; esc; ctrl-g
ViewContinueSearch = ctrl-r; ctrl-s; f17
ViewMoveToBol = home
ViewMoveToEol = end
ViewMoveToBol = ctrl-a
ViewMoveToEol = ctrl-e
ViewMoveLeft = h; left
ViewMoveRight = l; right
ViewMoveUp = k; y; insert; up
ViewMoveDown = j; e; delete; down
ViewMoveDown = j; e; delete; down; enter
ViewMovePgDn = f; space; pgdn
ViewMovePgUp = b; pgup
ViewMoveHalfPgDn = d
@ -178,13 +186,21 @@ ViewGotoBookmark = m
ViewNewBookmark = r
ViewNextFile = ctrl-f
ViewPrevFile = ctrl-b
ViewQuit = q; esc
SelectCodepage = alt-e
ShowCommandLine = ctrl-o
ViewToggleRuler = alt-r
[viewer:hex]
HexViewToggleNavigationMode = tab
ViewHelp = f1
ViewToggleHexEditMode = f2
ViewQuit = f3; f10; q; esc; ctrl-g
ViewToggleHexMode = f4
ViewGoto = f5
ViewHexEditSave = f6
ViewSearch = f7; question; slash
ViewToggleMagicMode = f8
ViewToggleNroffMode = f9
ViewToggleHexNavMode = tab
ViewMoveToBol = ctrl-a; home
ViewMoveToEol = ctrl-e; end
ViewMoveLeft = b; left
@ -285,7 +301,6 @@ PanelSortOrderByExt=
PanelSortOrderBySize=
PanelSortOrderByMTime=
[panel:xmap]
[input]

View File

@ -231,27 +231,34 @@
#define CK_InputPaste 4025
#define CK_InputClearLine 4026
/* Viewer */
#define CK_ViewSearch 5001
#define CK_ViewContinueSearch 5002
#define CK_ViewGotoBookmark 5003
#define CK_ViewNewBookmark 5004
#define CK_ViewMoveUp 5005
#define CK_ViewMoveDown 5006
#define CK_ViewMoveLeft 5007
#define CK_ViewMoveRight 5008
#define CK_ViewMovePgDn 5009
#define CK_ViewMovePgUp 5010
#define CK_ViewMoveHalfPgDn 5011
#define CK_ViewMoveHalfPgUp 5012
#define CK_ViewMoveToBol 5013
#define CK_ViewMoveToEol 5014
#define CK_ViewNextFile 5015
#define CK_ViewPrevFile 5016
#define CK_ViewToggleRuler 5017
#define CK_HexViewToggleNavigationMode 5018
#define CK_ViewQuit 5020
#define CK_ViewHelp 5001
#define CK_ViewToggleWrapMode 5002
#define CK_ViewToggleHexEditMode 5003
#define CK_ViewToggleHexMode 5004
#define CK_ViewGoto 5005
#define CK_ViewHexEditSave 5006
#define CK_ViewSearch 5007
#define CK_ViewToggleMagicMode 5008
#define CK_ViewToggleNroffMode 5009
#define CK_ViewQuit 5010
#define CK_ViewContinueSearch 5011
#define CK_ViewGotoBookmark 5012
#define CK_ViewNewBookmark 5013
#define CK_ViewMoveUp 5014
#define CK_ViewMoveDown 5015
#define CK_ViewMoveLeft 5016
#define CK_ViewMoveRight 5017
#define CK_ViewMovePgDn 5018
#define CK_ViewMovePgUp 5019
#define CK_ViewMoveHalfPgDn 5020
#define CK_ViewMoveHalfPgUp 5021
#define CK_ViewMoveToBol 5022
#define CK_ViewMoveToEol 5023
#define CK_ViewNextFile 5024
#define CK_ViewPrevFile 5025
#define CK_ViewToggleRuler 5026
#define CK_ViewToggleHexNavMode 5027
/* Tree */
#define CK_TreeHelp 6001

View File

@ -220,7 +220,16 @@ static name_keymap_t command_names[] = {
#endif /* USE_INTERNAL_EDIT */
/* viewer */
{ "ViewHelp", CK_ViewHelp },
{ "ViewToggleWrapMode", CK_ViewToggleWrapMode },
{ "ViewToggleHexEditMode", CK_ViewToggleHexEditMode },
{ "ViewQuit", CK_ViewQuit },
{ "ViewToggleHexMode", CK_ViewToggleHexMode },
{ "ViewGoto", CK_ViewGoto },
{ "ViewHexEditSave", CK_ViewHexEditSave },
{ "ViewSearch", CK_ViewSearch },
{ "ViewToggleMagicMode", CK_ViewToggleMagicMode },
{ "ViewToggleNroffMode", CK_ViewToggleNroffMode },
{ "ViewContinueSearch", CK_ViewContinueSearch },
{ "ViewGotoBookmark", CK_ViewGotoBookmark },
{ "ViewNewBookmark", CK_ViewNewBookmark },
@ -237,8 +246,7 @@ static name_keymap_t command_names[] = {
{ "ViewNextFile", CK_ViewNextFile },
{ "ViewPrevFile", CK_ViewPrevFile },
{ "ViewToggleRuler", CK_ViewToggleRuler },
{ "HexViewToggleNavigationMode", CK_HexViewToggleNavigationMode },
{ "ViewQuit", CK_ViewQuit },
{ "ViewToggleHexNavMode", CK_ViewToggleHexNavMode },
/* tree */
{ "TreeHelp", CK_TreeHelp },
@ -432,77 +440,112 @@ static const size_t num_command_names = sizeof (command_names) /
/* viewer/actions_cmd.c */
const global_keymap_t default_viewer_keymap[] = {
{ '?', CK_ViewSearch, "?" },
{ '/', CK_ViewSearch, "/" },
{ XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
{ XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
{ KEY_F (17), CK_ViewContinueSearch, "S-F7" },
{ 'n', CK_ViewContinueSearch, "n" },
{ ALT ('r'), CK_ViewToggleRuler, "M-r" },
{ KEY_F (1), CK_ViewHelp, "F1" },
{ KEY_F (2), CK_ViewToggleWrapMode, "F2" },
{ KEY_F (3), CK_ViewQuit, "F3" },
{ KEY_F (4), CK_ViewToggleHexMode, "F4" },
{ KEY_F (5), CK_ViewGoto, "F5" },
{ KEY_F (7), CK_ViewSearch, "F7" },
{ KEY_F (8), CK_ViewToggleMagicMode, "F8" },
{ KEY_F (9), CK_ViewToggleNroffMode, "F9" },
{ KEY_F (10), CK_ViewQuit, "F10" },
{ XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
{ XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
{ '?', CK_ViewSearch, "?" },
{ '/', CK_ViewSearch, "/" },
{ XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
{ XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
{ KEY_F (17), CK_ViewContinueSearch, "S-F7" },
{ 'n', CK_ViewContinueSearch, "n" },
{ ALT ('r'), CK_ViewToggleRuler, "M-r" },
{ 'h', CK_ViewMoveLeft, "h" },
{ KEY_LEFT, CK_ViewMoveLeft, "Left" },
{ XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
{ XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
{ 'l', CK_ViewMoveRight, "l" },
{ KEY_RIGHT, CK_ViewMoveRight, "Right" },
{ 'h', CK_ViewMoveLeft, "h" },
{ KEY_LEFT, CK_ViewMoveLeft, "Left" },
{ 'k', CK_ViewMoveUp, "k" },
{ 'y', CK_ViewMoveUp, "y" },
{ KEY_IC, CK_ViewMoveUp, "Insert" },
{ KEY_UP, CK_ViewMoveUp, "Up" },
{ 'l', CK_ViewMoveRight, "l" },
{ KEY_RIGHT, CK_ViewMoveRight, "Right" },
{ 'j', CK_ViewMoveDown, "j" },
{ 'e', CK_ViewMoveDown, "e" },
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
{ KEY_DC, CK_ViewMoveDown, "Delete" },
{ 'k', CK_ViewMoveUp, "k" },
{ 'y', CK_ViewMoveUp, "y" },
{ KEY_IC, CK_ViewMoveUp, "Insert" },
{ KEY_UP, CK_ViewMoveUp, "Up" },
{ ' ', CK_ViewMovePgDn, "Space" },
{ 'f', CK_ViewMovePgDn, "f" },
{ KEY_NPAGE, CK_ViewMovePgDn, "PgDn" },
{ 'j', CK_ViewMoveDown, "j" },
{ 'e', CK_ViewMoveDown, "e" },
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
{ KEY_DC, CK_ViewMoveDown, "Delete" },
{ 'b', CK_ViewMovePgUp, "b" },
{ KEY_PPAGE, CK_ViewMovePgUp, "PgUp" },
{ ' ', CK_ViewMovePgDn, "Space" },
{ 'f', CK_ViewMovePgDn, "f" },
{ KEY_NPAGE, CK_ViewMovePgDn, "PgDn" },
{ 'd', CK_ViewMoveHalfPgDn, "d" },
{ 'u', CK_ViewMoveHalfPgUp, "u" },
{ 'b', CK_ViewMovePgUp, "b" },
{ KEY_PPAGE, CK_ViewMovePgUp, "PgUp" },
{ 'm', CK_ViewGotoBookmark, "m" },
{ 'r', CK_ViewNewBookmark, "r" },
{ 'd', CK_ViewMoveHalfPgDn, "d" },
{ 'u', CK_ViewMoveHalfPgUp, "u" },
{ XCTRL ('f'), CK_ViewNextFile, "C-f" },
{ XCTRL ('b'), CK_ViewPrevFile, "C-b" },
{ 'm', CK_ViewGotoBookmark, "m" },
{ 'r', CK_ViewNewBookmark, "r" },
{ 'q', CK_ViewQuit, "q" },
{ XCTRL ('g'), CK_ViewQuit, "C-q" },
{ ESC_CHAR, CK_ViewQuit, "Esc" },
{ XCTRL ('f'), CK_ViewNextFile, "C-f" },
{ XCTRL ('b'), CK_ViewPrevFile, "C-b" },
{ ALT ('e'), CK_SelectCodepage, "M-e" },
{ XCTRL ('o'), CK_ShowCommandLine, "C-o" },
{ 'q', CK_ViewQuit, "q" },
{ XCTRL ('g'), CK_ViewQuit, "C-g" },
{ ESC_CHAR, CK_ViewQuit, "Esc" },
{ ALT ('e'), CK_SelectCodepage, "M-e" },
{ XCTRL ('o'), CK_ShowCommandLine, "C-o" },
{ 0, CK_Ignore_Key, "" }
};
const global_keymap_t default_viewer_hex_keymap[] = {
{ '\t', CK_HexViewToggleNavigationMode, "Tab" },
{ XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
{ XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
{ KEY_F (1), CK_ViewHelp, "F1" },
{ KEY_F (2), CK_ViewToggleHexEditMode, "F2" },
{ KEY_F (3), CK_ViewQuit, "F3" },
{ KEY_F (4), CK_ViewToggleHexMode, "F4" },
{ KEY_F (5), CK_ViewGoto, "F5" },
{ KEY_F (6), CK_ViewHexEditSave, "F6" },
{ KEY_F (7), CK_ViewSearch, "F7" },
{ KEY_F (8), CK_ViewToggleMagicMode, "F8" },
{ KEY_F (9), CK_ViewToggleNroffMode, "F9" },
{ KEY_F (10), CK_ViewQuit, "F10" },
{ 'b', CK_ViewMoveLeft, "b" },
{ KEY_LEFT, CK_ViewMoveLeft, "Left" },
{ '?', CK_ViewSearch, "?" },
{ '/', CK_ViewSearch, "/" },
{ XCTRL ('r'), CK_ViewContinueSearch, "C-r" },
{ XCTRL ('s'), CK_ViewContinueSearch, "C-s" },
{ KEY_F (17), CK_ViewContinueSearch, "S-F7" },
{ 'n', CK_ViewContinueSearch, "n" },
{ 'f', CK_ViewMoveRight, "f" },
{ KEY_RIGHT, CK_ViewMoveRight, "Right" },
{ '\t', CK_ViewToggleHexNavMode, "Tab" },
{ XCTRL ('a'), CK_ViewMoveToBol, "C-a" },
{ XCTRL ('e'), CK_ViewMoveToEol, "C-e" },
{ 'k', CK_ViewMoveUp, "k" },
{ 'y', CK_ViewMoveUp, "y" },
{ KEY_UP, CK_ViewMoveUp, "Up" },
{ 'b', CK_ViewMoveLeft, "b" },
{ KEY_LEFT, CK_ViewMoveLeft, "Left" },
{ 'j', CK_ViewMoveDown, "j" },
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
{ KEY_DC, CK_ViewMoveDown, "Delete" },
{ 'f', CK_ViewMoveRight, "f" },
{ KEY_RIGHT, CK_ViewMoveRight, "Right" },
{ 'k', CK_ViewMoveUp, "k" },
{ 'y', CK_ViewMoveUp, "y" },
{ KEY_UP, CK_ViewMoveUp, "Up" },
{ 'j', CK_ViewMoveDown, "j" },
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
{ KEY_DC, CK_ViewMoveDown, "Delete" },
{ 'q', CK_ViewQuit, "q" },
{ XCTRL ('g'), CK_ViewQuit, "C-g" },
{ ESC_CHAR, CK_ViewQuit, "Esc" },
{ ALT ('e'), CK_SelectCodepage, "M-e" },
{ XCTRL ('o'), CK_ShowCommandLine, "C-o" },
{ 0, CK_Ignore_Key, "" }
};

View File

@ -66,7 +66,6 @@
#include "../src/keybind.h"
#include "../src/cmddef.h" /* CK_ cmd name const */
#include "internal.h"
#include "mcviewer.h"
@ -85,7 +84,6 @@
static void
mcview_continue_search_cmd (mcview_t * view)
{
if (view->last_search_string != NULL) {
mcview_do_search (view);
} else {
@ -200,6 +198,50 @@ mcview_cmk_moveto_bottom (void *w, int n)
/* --------------------------------------------------------------------------------------------- */
static inline void
mcview_moveto_line_cmd (mcview_t *view)
{
char *answer, *answer_end, prompt[BUF_SMALL];
off_t line, col;
mcview_offset_to_coord (view, &line, &col, view->dpy_start);
g_snprintf (prompt, sizeof (prompt),
_(" The current line number is %lld.\n"
" Enter the new line number:"), (line + 1));
answer = input_dialog (_(" Goto line "), prompt, MC_HISTORY_VIEW_GOTO_LINE, "");
if (answer != NULL && answer[0] != '\0') {
errno = 0;
line = strtoul (answer, &answer_end, 10);
if (errno == 0 && *answer_end == '\0' && line >= 1)
mcview_moveto (view, line - 1, 0);
}
g_free (answer);
}
static inline void
mcview_moveto_addr_cmd (mcview_t *view)
{
char *line, *error, prompt[BUF_SMALL], prompt_format[BUF_SMALL];
g_snprintf (prompt_format, sizeof (prompt_format),
_(" The current address is %s.\n"
" Enter the new address:"), "0x%08" OFFSETTYPE_PRIX "");
g_snprintf (prompt, sizeof (prompt), prompt_format, view->hex_cursor);
line = input_dialog (_(" Goto Address "), prompt, MC_HISTORY_VIEW_GOTO_ADDR, "");
if ((line != NULL) && (*line != '\0')) {
off_t addr;
addr = strtoul (line, &error, 0);
if ((*error == '\0') && mcview_get_byte (view, addr, NULL))
mcview_moveto_offset (view, addr);
else
message (D_ERROR, _("Warning"), _(" Invalid address "));
}
g_free (line);
}
/* --------------------------------------------------------------------------------------------- */
static void
mcview_hook (void *v)
{
@ -228,6 +270,7 @@ mcview_hook (void *v)
}
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t
mcview_handle_editkey (mcview_t * view, int key)
{
@ -294,7 +337,42 @@ mcview_execute_cmd (Widget *sender, Widget *receiver,
(void) data;
switch (command) {
case CK_HexViewToggleNavigationMode:
case CK_ViewHelp:
interactive_display (NULL, "[Internal File Viewer]");
break;
case CK_ViewToggleWrapMode:
/* Toggle between wrapped and unwrapped view */
mcview_toggle_wrap_mode (view);
mcview_update (view); /* FIXME: view->dirty++ ? */
break;
case CK_ViewToggleHexEditMode:
/* Toggle between hexview and hexedit mode */
mcview_toggle_hexedit_mode (view);
mcview_update (view); /* FIXME: view->dirty++ ? */
break;
case CK_ViewToggleHexMode:
/* Toggle between hex view and text view */
mcview_toggle_hex_mode (view);
mcview_update (view); /* FIXME: view->dirty++ ? */
break;
case CK_ViewGoto:
mcview_goto (view);
break;
case CK_ViewHexEditSave:
mcview_hexedit_save_changes (view);
break;
case CK_ViewSearch:
mcview_search_cmd (view);
break;
case CK_ViewToggleMagicMode:
mcview_toggle_magic_mode (view);
mcview_update (view); /* FIXME: view->dirty++ ? */
break;
case CK_ViewToggleNroffMode:
mcview_toggle_nroff_mode (view);
mcview_update (view); /* FIXME: view->dirty++ ? */
break;
case CK_ViewToggleHexNavMode:
view->hexview_in_text = !view->hexview_in_text;
view->dirty++;
break;
@ -311,17 +389,12 @@ mcview_execute_cmd (Widget *sender, Widget *receiver,
case CK_ViewMoveRight:
mcview_move_right (view, 1);
break;
case CK_ViewSearch:
view->search_type = MC_SEARCH_T_REGEX;
mcview_search_cmd (view);
break;
/* Continue search */
case CK_ViewContinueSearch:
mcview_continue_search_cmd (view);
break;
/* toggle ruler */
case CK_ViewToggleRuler:
mcview_toggle_ruler_cmd (view);
mcview_display_toggle_ruler (view);
break;
case CK_ViewMoveUp:
mcview_move_up (view, 1);
@ -364,7 +437,7 @@ mcview_execute_cmd (Widget *sender, Widget *receiver,
break;
case CK_ViewNextFile:
case CK_ViewPrevFile:
/* Use to indicate parent that we want to see the next/previous file */
/* Use to indicate parent that we want to see the next/previous file */
/* Does not work in panel mode */
if (!mcview_is_in_panel (view))
view->move_dir = (command == CK_ViewNextFile) ? 1 : -1;
@ -379,7 +452,6 @@ mcview_execute_cmd (Widget *sender, Widget *receiver,
return res;
}
/* Both views */
static cb_ret_t
mcview_handle_key (mcview_t * view, int key)
@ -462,9 +534,8 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
i = mcview_handle_key ((mcview_t *) view, parm);
if (view->want_to_quit && !mcview_is_in_panel (view))
dlg_stop (h);
else {
else
mcview_update (view);
}
return i;
case WIDGET_FOCUS:
@ -503,7 +574,21 @@ mcview_dialog_callback (Dlg_head * h, dlg_msg_t msg, int parm)
void
mcview_help_cmd (void)
{
interactive_display (NULL, "[Internal File Viewer]");
mcview_execute_cmd (NULL, NULL, CK_ViewHelp, NULL);
}
/* --------------------------------------------------------------------------------------------- */
void
mcview_goto (mcview_t *view)
{
if (view->hex_mode)
mcview_moveto_addr_cmd (view);
else
mcview_moveto_line_cmd (view);
view->dirty++;
mcview_update (view); /* FIXME: unneeded? */
}
/* --------------------------------------------------------------------------------------------- */
@ -511,8 +596,9 @@ mcview_help_cmd (void)
void
mcview_quit_cmd (mcview_t * view)
{
if (mcview_ok_to_quit (view))
dlg_stop (view->widget.parent);
mcview_execute_cmd (NULL, &view->widget, CK_ViewQuit, NULL);
if (view->want_to_quit)
dlg_stop (view->widget.parent);
}
/* --------------------------------------------------------------------------------------------- */
@ -521,61 +607,7 @@ mcview_quit_cmd (mcview_t * view)
void
mcview_toggle_hex_mode_cmd (mcview_t * view)
{
mcview_toggle_hex_mode (view);
mcview_update (view);
}
/* --------------------------------------------------------------------------------------------- */
void
mcview_moveto_line_cmd (mcview_t * view)
{
char *answer, *answer_end, prompt[BUF_SMALL];
off_t line, col;
mcview_offset_to_coord (view, &line, &col, view->dpy_start);
g_snprintf (prompt, sizeof (prompt),
_(" The current line number is %lld.\n"
" Enter the new line number:"), (line + 1));
answer = input_dialog (_(" Goto line "), prompt, MC_HISTORY_VIEW_GOTO_LINE, "");
if (answer != NULL && answer[0] != '\0') {
errno = 0;
line = strtoul (answer, &answer_end, 10);
if (*answer_end == '\0' && errno == 0 && line >= 1)
mcview_moveto (view, line - 1, 0);
}
g_free (answer);
view->dirty++;
mcview_update (view);
}
/* --------------------------------------------------------------------------------------------- */
void
mcview_moveto_addr_cmd (mcview_t * view)
{
char *line, *error, prompt[BUF_SMALL], prompt_format[BUF_SMALL];
off_t addr;
g_snprintf (prompt_format, sizeof (prompt_format),
_(" The current address is %s.\n"
" Enter the new address:"), "0x%08" OFFSETTYPE_PRIX "");
g_snprintf (prompt, sizeof (prompt), prompt_format, view->hex_cursor);
line = input_dialog (_(" Goto Address "), prompt, MC_HISTORY_VIEW_GOTO_ADDR, "");
if (line != NULL) {
if (*line != '\0') {
addr = strtoul (line, &error, 0);
if ((*error == '\0') && mcview_get_byte (view, addr, NULL) == TRUE) {
mcview_moveto_offset (view, addr);
} else {
message (D_ERROR, _("Warning"), _(" Invalid address "));
}
}
g_free (line);
}
view->dirty++;
mcview_update (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleHexMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -584,8 +616,7 @@ mcview_moveto_addr_cmd (mcview_t * view)
void
mcview_toggle_hexedit_mode_cmd (mcview_t * view)
{
mcview_toggle_hexedit_mode (view);
mcview_update (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleHexEditMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -593,7 +624,7 @@ mcview_toggle_hexedit_mode_cmd (mcview_t * view)
void
mcview_hexedit_save_changes_cmd (mcview_t * view)
{
(void) mcview_hexedit_save_changes (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewHexEditSave, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -602,8 +633,7 @@ mcview_hexedit_save_changes_cmd (mcview_t * view)
void
mcview_toggle_wrap_mode_cmd (mcview_t * view)
{
mcview_toggle_wrap_mode (view);
mcview_update (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleWrapMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -612,8 +642,7 @@ mcview_toggle_wrap_mode_cmd (mcview_t * view)
void
mcview_search_cmd (mcview_t * view)
{
if (mcview_dialog_search (view))
mcview_do_search (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleMagicMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -621,8 +650,7 @@ mcview_search_cmd (mcview_t * view)
void
mcview_toggle_magic_mode_cmd (mcview_t * view)
{
mcview_toggle_magic_mode (view);
mcview_update (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleMagicMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -630,16 +658,7 @@ mcview_toggle_magic_mode_cmd (mcview_t * view)
void
mcview_toggle_nroff_mode_cmd (mcview_t * view)
{
mcview_toggle_nroff_mode (view);
mcview_update (view);
}
/* --------------------------------------------------------------------------------------------- */
void
mcview_toggle_ruler_cmd (mcview_t * view)
{
mcview_display_toggle_ruler (view);
mcview_execute_cmd (NULL, &view->widget, CK_ViewToggleNroffMode, NULL);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -42,6 +42,10 @@
#include "../src/tty/tty.h"
#include "../src/tty/key.h"
#include "../src/strutil.h"
#include "../src/main.h"
#include "../src/dialog.h" /* Dlg_head */
#include "../src/widget.h" /* WButtonBar */
#include "internal.h"
#include "mcviewer.h"
@ -66,7 +70,7 @@ static enum ruler_type {
/* Define labels and handlers for functional keys */
static void
mcview_labels (mcview_t * view)
mcview_set_buttonbar (mcview_t *view)
{
const char *text;
Dlg_head *h = view->widget.parent;
@ -86,8 +90,6 @@ mcview_labels (mcview_t * view)
buttonbar_set_label_data (b, 4, Q_ ("ButtonBar|Ascii"),
(buttonbarfn) mcview_toggle_hex_mode_cmd, view);
buttonbar_set_label_data (b, 5, Q_ ("ButtonBar|Goto"),
(buttonbarfn) mcview_moveto_addr_cmd, view);
buttonbar_set_label_data (b, 6, Q_ ("ButtonBar|Save"),
(buttonbarfn) mcview_hexedit_save_changes_cmd, view);
buttonbar_set_label_data (b, 7, Q_ ("ButtonBar|HxSrch"),
@ -96,16 +98,16 @@ mcview_labels (mcview_t * view)
text = view->text_wrap_mode ? Q_ ("ButtonBar|UnWrap") : Q_ ("ButtonBar|Wrap");
buttonbar_set_label_data (b, 2, text,
(buttonbarfn) mcview_toggle_wrap_mode_cmd, view);
buttonbar_set_label_data (b, 4, Q_ ("ButtonBar|Hex"),
(buttonbarfn) mcview_toggle_hex_mode_cmd, view);
buttonbar_set_label_data (b, 5, Q_ ("ButtonBar|Line"),
(buttonbarfn) mcview_moveto_line_cmd, view);
buttonbar_clear_label (b, 6);
buttonbar_set_label_data (b, 7, Q_ ("ButtonBar|Search"),
(buttonbarfn) mcview_search_cmd, view);
}
buttonbar_set_label_data (b, 5, Q_ ("ButtonBar|Goto"),
(buttonbarfn) mcview_goto, view);
/* don't override the key to access the main menu */
if (!mcview_is_in_panel (view)) {
buttonbar_set_label_data (b, 3, Q_ ("ButtonBar|Quit"),
@ -201,7 +203,7 @@ mcview_update (mcview_t * view)
if (view->dpy_bbar_dirty) {
view->dpy_bbar_dirty = FALSE;
mcview_labels (view);
mcview_set_buttonbar (view);
buttonbar_redraw (find_buttonbar (view->widget.parent));
}
@ -336,7 +338,6 @@ mcview_display_toggle_ruler (mcview_t * view)
assert ((size_t) ruler < 3);
ruler = next[(size_t) ruler];
view->dirty++;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1,3 +1,4 @@
#ifndef MC_VIEWER_INTERNAL_H
#define MC_VIEWER_INTERNAL_H
@ -198,33 +199,29 @@ typedef struct mcview_nroff_struct {
/*** declarations of public functions **********************************/
/* actions_cmd.c: */
cb_ret_t mcview_callback (Widget *, widget_msg_t, int);
cb_ret_t mcview_dialog_callback (Dlg_head *, dlg_msg_t, int);
void mcview_help_cmd (void);
void mcview_quit_cmd (mcview_t *);
void mcview_toggle_hex_mode_cmd (mcview_t *);
void mcview_moveto_line_cmd (mcview_t *);
void mcview_moveto_addr_cmd (mcview_t *);
void mcview_toggle_hexedit_mode_cmd (mcview_t *);
void mcview_hexedit_save_changes_cmd (mcview_t *);
void mcview_toggle_wrap_mode_cmd (mcview_t *);
void mcview_search_cmd (mcview_t *);
void mcview_toggle_magic_mode_cmd (mcview_t *);
void mcview_toggle_nroff_mode_cmd (mcview_t *);
void mcview_toggle_ruler_cmd (mcview_t *);
void mcview_quit_cmd (mcview_t *view);
void mcview_goto (mcview_t *view);
void mcview_toggle_hex_mode_cmd (mcview_t *view);
void mcview_toggle_hexedit_mode_cmd (mcview_t *view);
void mcview_hexedit_save_changes_cmd (mcview_t *view);
void mcview_toggle_wrap_mode_cmd (mcview_t *view);
void mcview_search_cmd (mcview_t *view);
void mcview_toggle_magic_mode_cmd (mcview_t *view);
void mcview_toggle_nroff_mode_cmd (mcview_t *view);
cb_ret_t mcview_callback (Widget *w, widget_msg_t msg, int parm);
cb_ret_t mcview_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm);
/* coord_cache.c: */
gboolean mcview_coord_cache_entry_less (const struct coord_cache_entry *,
const struct coord_cache_entry *, enum ccache_type,
gboolean);
#ifdef MC_ENABLE_DEBUGGING_CODE
void mcview_ccache_dump (mcview_t *);
void mcview_ccache_dump (mcview_t *view);
#endif
void
mcview_ccache_lookup (mcview_t *, struct coord_cache_entry *, enum ccache_type);
void mcview_ccache_lookup (mcview_t *view, struct coord_cache_entry *coord,
enum ccache_type lookup_what);
/* datasource.c: */
void mcview_set_datasource_none (mcview_t *);
@ -246,41 +243,41 @@ void mcview_set_datasource_string (mcview_t *, const char *);
gboolean mcview_dialog_search (mcview_t *);
/* display.c: */
void mcview_update (mcview_t *);
void mcview_display (mcview_t *);
void mcview_compute_areas (mcview_t *);
void mcview_update_bytes_per_line (mcview_t *);
void mcview_display_toggle_ruler (mcview_t *);
void mcview_display_clean (mcview_t *);
void mcview_display_ruler (mcview_t *);
void mcview_adjust_size (Dlg_head *);
void mcview_percent (mcview_t *, off_t);
void mcview_update (mcview_t *view);
void mcview_display (mcview_t *view);
void mcview_compute_areas (mcview_t *view);
void mcview_update_bytes_per_line (mcview_t *view);
void mcview_display_toggle_ruler (mcview_t *view);
void mcview_display_clean (mcview_t *view);
void mcview_display_ruler (mcview_t *view);
void mcview_adjust_size (Dlg_head *h);
void mcview_percent (mcview_t *view, off_t p);
/* growbuf.c: */
void mcview_growbuf_init (mcview_t *);
void mcview_growbuf_free (mcview_t *);
off_t mcview_growbuf_filesize (mcview_t *);
void mcview_growbuf_read_until (mcview_t *, off_t);
gboolean mcview_get_byte_growing_buffer (mcview_t *, off_t, int *);
char *mcview_get_ptr_growing_buffer (mcview_t *, off_t);
void mcview_growbuf_init (mcview_t *view);
void mcview_growbuf_free (mcview_t *view);
off_t mcview_growbuf_filesize (mcview_t *view);
void mcview_growbuf_read_until (mcview_t *view, off_t p);
gboolean mcview_get_byte_growing_buffer (mcview_t *view, off_t p, int *);
char *mcview_get_ptr_growing_buffer (mcview_t *view, off_t p);
/* hex.c: */
void mcview_display_hex (mcview_t *);
gboolean mcview_hexedit_save_changes (mcview_t *);
void mcview_toggle_hexedit_mode (mcview_t *);
void mcview_hexedit_free_change_list (mcview_t *);
void mcview_display_hex (mcview_t *view);
gboolean mcview_hexedit_save_changes (mcview_t *view);
void mcview_toggle_hexedit_mode (mcview_t *view);
void mcview_hexedit_free_change_list (mcview_t *view);
void mcview_enqueue_change (struct hexedit_change_node **, struct hexedit_change_node *);
/* lib.c: */
void mcview_toggle_magic_mode (mcview_t *);
void mcview_toggle_wrap_mode (mcview_t *);
void mcview_toggle_nroff_mode (mcview_t *);
void mcview_toggle_hex_mode (mcview_t *);
gboolean mcview_ok_to_quit (mcview_t *);
void mcview_done (mcview_t *);
void mcview_select_encoding (mcview_t *);
void mcview_set_codeset (mcview_t *);
void mcview_show_error (mcview_t *, const char *);
void mcview_toggle_magic_mode (mcview_t *view);
void mcview_toggle_wrap_mode (mcview_t *view);
void mcview_toggle_nroff_mode (mcview_t *view);
void mcview_toggle_hex_mode (mcview_t *view);
gboolean mcview_ok_to_quit (mcview_t *view);
void mcview_done (mcview_t *view);
void mcview_select_encoding (mcview_t *view);
void mcview_set_codeset (mcview_t *view);
void mcview_show_error (mcview_t *view, const char *error);
/* move.c */
void mcview_move_up (mcview_t *, off_t);
@ -300,10 +297,10 @@ void mcview_place_cursor (mcview_t *);
void mcview_moveto_match (mcview_t *);
/* nroff.c: */
void mcview_display_nroff (mcview_t *);
int mcview__get_nroff_real_len (mcview_t *, off_t, off_t);
void mcview_display_nroff (mcview_t *view);
int mcview__get_nroff_real_len (mcview_t *view, off_t, off_t p);
mcview_nroff_t *mcview_nroff_seq_new_num (mcview_t * view, off_t);
mcview_nroff_t *mcview_nroff_seq_new_num (mcview_t *view, off_t p);
mcview_nroff_t *mcview_nroff_seq_new (mcview_t * view);
void mcview_nroff_seq_free (mcview_nroff_t **);
nroff_type_t mcview_nroff_seq_info (mcview_nroff_t *);
@ -315,11 +312,11 @@ void mcview_display_text (mcview_t *);
/* search.c: */
int mcview_search_cmd_callback (const void *user_data, gsize char_offset);
int mcview_search_update_cmd_callback (const void *, gsize);
void mcview_do_search (mcview_t *);
void mcview_do_search (mcview_t *view);
/*** inline functions ****************************************************************************/
#include "inlines.h"
#endif
#endif /* MC_VIEWER_INTERNAL_H */

View File

@ -48,6 +48,7 @@
#include "../src/charsets.h"
#include "../src/main-widgets.h" /* the_menubar */
#include "../src/menu.h" /* menubar_visible */
#include "../src/widget.h"
#include "internal.h"
#include "mcviewer.h"
@ -266,13 +267,12 @@ mcview_viewer (const char *command, const char *file, int *move_dir_p, int start
Dlg_head *view_dlg;
/* Create dialog and widgets, put them on the dialog */
view_dlg =
create_dlg (0, 0, LINES, COLS, NULL, mcview_dialog_callback,
"[Internal File Viewer]", NULL, DLG_WANT_TAB);
view_dlg = create_dlg (0, 0, LINES, COLS, NULL, mcview_dialog_callback,
"[Internal File Viewer]", NULL, DLG_WANT_TAB);
lc_mcview = mcview_new (0, 0, COLS, LINES - 1, 0);
add_widget (view_dlg, lc_mcview);
add_widget (view_dlg, buttonbar_new (TRUE));
succeeded = mcview_load (lc_mcview, command, file, start_line);

View File

@ -242,7 +242,6 @@ mcview_do_search (mcview_t * view)
view->dirty++;
mcview_update (view);
tty_disable_interrupt_key ();
if (verbose) {
dlg_run_done (d);