mirror of https://github.com/MidnightCommander/mc
Merge branch '1754_show_current_syntax'
* 1754_show_current_syntax: Applied MC indentation policy. Optimization: rid of edit_menubar global variable. Optimization: rid of wedit and option_syntax_type global variables. Type accuracy. Minor optimization. Ticket #1754: show current syntax in 'Choose syntax highlighting' dialog.
This commit is contained in:
commit
5ba9fde28c
|
@ -25,93 +25,92 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "src/wtools.h"
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
|
||||
#define MAX_ENTRY_LEN 40
|
||||
#define LIST_LINES 14
|
||||
#define N_DFLT_ENTRIES 2
|
||||
|
||||
static int
|
||||
pstrcmp(const void *p1, const void *p2)
|
||||
pstrcmp (const void *p1, const void *p2)
|
||||
{
|
||||
return strcmp(*(char**)p1, *(char**)p2);
|
||||
return strcmp (*(char **) p1, *(char **) p2);
|
||||
}
|
||||
|
||||
static int
|
||||
exec_edit_syntax_dialog (const char **names) {
|
||||
int i;
|
||||
exec_edit_syntax_dialog (const char **names, const char *current_syntax)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
Listbox *syntaxlist = create_listbox_window (LIST_LINES, MAX_ENTRY_LEN,
|
||||
_(" Choose syntax highlighting "), NULL);
|
||||
_(" Choose syntax highlighting "), NULL);
|
||||
LISTBOX_APPEND_TEXT (syntaxlist, 'A', _("< Auto >"), NULL);
|
||||
LISTBOX_APPEND_TEXT (syntaxlist, 'R', _("< Reload Current Syntax >"), NULL);
|
||||
|
||||
for (i = 0; names[i]; i++) {
|
||||
LISTBOX_APPEND_TEXT (syntaxlist, 0, names[i], NULL);
|
||||
if (! option_auto_syntax && option_syntax_type
|
||||
&& (strcmp (names[i], option_syntax_type) == 0))
|
||||
listbox_select_entry (syntaxlist->list, i + N_DFLT_ENTRIES);
|
||||
for (i = 0; names[i] != NULL; i++)
|
||||
{
|
||||
LISTBOX_APPEND_TEXT (syntaxlist, 0, names[i], NULL);
|
||||
if ((current_syntax != NULL) && (strcmp (names[i], current_syntax) == 0))
|
||||
listbox_select_entry (syntaxlist->list, i + N_DFLT_ENTRIES);
|
||||
}
|
||||
|
||||
return run_listbox (syntaxlist);
|
||||
}
|
||||
|
||||
void
|
||||
edit_syntax_dialog (void) {
|
||||
edit_syntax_dialog (WEdit * edit, const char *current_syntax)
|
||||
{
|
||||
char *old_syntax_type;
|
||||
int old_auto_syntax, syntax;
|
||||
char **names;
|
||||
int i;
|
||||
int force_reload = 0;
|
||||
int count = 0;
|
||||
gboolean force_reload = FALSE;
|
||||
size_t count;
|
||||
|
||||
names = g_new0 (char *, 1);
|
||||
|
||||
names = (char**) g_malloc (sizeof (char*));
|
||||
names[0] = NULL;
|
||||
/* We fill the list of syntax files every time the editor is invoked.
|
||||
Instead we could save the list to a file and update it once the syntax
|
||||
file gets updated (either by testing or by explicit user command). */
|
||||
edit_load_syntax (NULL, &names, NULL);
|
||||
while (names[count++] != NULL);
|
||||
qsort(names, count - 1, sizeof(char*), pstrcmp);
|
||||
count = g_strv_length (names);
|
||||
qsort (names, count, sizeof (char *), pstrcmp);
|
||||
|
||||
if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) {
|
||||
for (i = 0; names[i]; i++) {
|
||||
g_free (names[i]);
|
||||
}
|
||||
g_free (names);
|
||||
return;
|
||||
syntax = exec_edit_syntax_dialog ((const char **) names, current_syntax);
|
||||
if (syntax < 0)
|
||||
{
|
||||
g_strfreev (names);
|
||||
return;
|
||||
}
|
||||
|
||||
old_auto_syntax = option_auto_syntax;
|
||||
old_syntax_type = g_strdup (option_syntax_type);
|
||||
old_syntax_type = g_strdup (current_syntax);
|
||||
|
||||
switch (syntax) {
|
||||
case 0: /* auto syntax */
|
||||
option_auto_syntax = 1;
|
||||
break;
|
||||
case 1: /* reload current syntax */
|
||||
force_reload = 1;
|
||||
break;
|
||||
default:
|
||||
option_auto_syntax = 0;
|
||||
g_free (option_syntax_type);
|
||||
option_syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]);
|
||||
switch (syntax)
|
||||
{
|
||||
case 0: /* auto syntax */
|
||||
option_auto_syntax = 1;
|
||||
break;
|
||||
case 1: /* reload current syntax */
|
||||
force_reload = TRUE;
|
||||
break;
|
||||
default:
|
||||
option_auto_syntax = 0;
|
||||
g_free (edit->syntax_type);
|
||||
edit->syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]);
|
||||
}
|
||||
|
||||
/* Load or unload syntax rules if the option has changed */
|
||||
if ((option_auto_syntax && !old_auto_syntax) || old_auto_syntax ||
|
||||
(old_syntax_type && option_syntax_type &&
|
||||
(strcmp (old_syntax_type, option_syntax_type) != 0)) ||
|
||||
force_reload)
|
||||
edit_load_syntax (wedit, NULL, option_syntax_type);
|
||||
(old_syntax_type && edit->syntax_type &&
|
||||
(strcmp (old_syntax_type, edit->syntax_type) != 0)) || force_reload)
|
||||
edit_load_syntax (edit, NULL, edit->syntax_type);
|
||||
|
||||
for (i = 0; names[i]; i++) {
|
||||
g_free (names[i]);
|
||||
}
|
||||
g_free (names);
|
||||
g_strfreev (names);
|
||||
g_free (old_syntax_type);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Copyright (C) 1996, 1997, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Authors: 1996, 1997 Paul Sheer
|
||||
2009 Andrew Borodin
|
||||
2009 Andrew Borodin
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,7 +19,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
/** \file edit-impl.h
|
||||
* \brief Header: editor low level data handling and cursor fundamentals
|
||||
|
@ -32,18 +32,18 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/search.h" /* mc_search_type_t */
|
||||
#include "lib/search.h" /* mc_search_type_t */
|
||||
|
||||
#include "src/dialog.h" /* cb_ret_t */
|
||||
#include "src/keybind.h" /* global_keymap_t */
|
||||
#include "src/dialog.h" /* cb_ret_t */
|
||||
#include "src/keybind.h" /* global_keymap_t */
|
||||
|
||||
#include "src/editor/edit.h"
|
||||
|
||||
#define SEARCH_DIALOG_OPTION_NO_SCANF (1 << 0)
|
||||
#define SEARCH_DIALOG_OPTION_NO_REGEX (1 << 1)
|
||||
#define SEARCH_DIALOG_OPTION_NO_CASE (1 << 2)
|
||||
#define SEARCH_DIALOG_OPTION_BACKWARDS (1 << 3)
|
||||
#define SEARCH_DIALOG_OPTION_BOOKMARK (1 << 4)
|
||||
#define SEARCH_DIALOG_OPTION_NO_SCANF (1 << 0)
|
||||
#define SEARCH_DIALOG_OPTION_NO_REGEX (1 << 1)
|
||||
#define SEARCH_DIALOG_OPTION_NO_CASE (1 << 2)
|
||||
#define SEARCH_DIALOG_OPTION_BACKWARDS (1 << 3)
|
||||
#define SEARCH_DIALOG_OPTION_BOOKMARK (1 << 4)
|
||||
|
||||
#define EDIT_KEY_EMULATION_NORMAL 0
|
||||
#define EDIT_KEY_EMULATION_EMACS 1
|
||||
|
@ -59,8 +59,8 @@
|
|||
#define REDRAW_CHAR_ONLY (1 << 7)
|
||||
#define REDRAW_COMPLETELY (1 << 8)
|
||||
|
||||
#define EDIT_TEXT_HORIZONTAL_OFFSET 0
|
||||
#define EDIT_TEXT_VERTICAL_OFFSET 1
|
||||
#define EDIT_TEXT_HORIZONTAL_OFFSET 0
|
||||
#define EDIT_TEXT_VERTICAL_OFFSET 1
|
||||
|
||||
#define EDIT_RIGHT_EXTREME option_edit_right_extreme
|
||||
#define EDIT_LEFT_EXTREME option_edit_left_extreme
|
||||
|
@ -120,7 +120,8 @@
|
|||
#define LINE_STATE_WIDTH 8
|
||||
|
||||
/* search/replace options */
|
||||
typedef struct edit_search_options_t {
|
||||
typedef struct edit_search_options_t
|
||||
{
|
||||
mc_search_type_t type;
|
||||
gboolean case_sens;
|
||||
gboolean backwards;
|
||||
|
@ -129,25 +130,29 @@ typedef struct edit_search_options_t {
|
|||
gboolean all_codepages;
|
||||
} edit_search_options_t;
|
||||
|
||||
typedef struct edit_stack_type {
|
||||
typedef struct edit_stack_type
|
||||
{
|
||||
long line;
|
||||
char *filename;
|
||||
} edit_stack_type;
|
||||
|
||||
struct macro {
|
||||
struct macro
|
||||
{
|
||||
unsigned long command;
|
||||
int ch;
|
||||
};
|
||||
|
||||
/* type for file which is currently being edited */
|
||||
typedef enum {
|
||||
EDIT_FILE_COMMON = 0,
|
||||
EDIT_FILE_SYNTAX = 1,
|
||||
EDIT_FILE_MENU = 2
|
||||
typedef enum
|
||||
{
|
||||
EDIT_FILE_COMMON = 0,
|
||||
EDIT_FILE_SYNTAX = 1,
|
||||
EDIT_FILE_MENU = 2
|
||||
} edit_current_file_t;
|
||||
|
||||
/* line breaks */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
LB_ASIS = 0,
|
||||
LB_UNIX,
|
||||
LB_WIN,
|
||||
|
@ -161,11 +166,11 @@ struct WMenuBar;
|
|||
extern const char VERTICAL_MAGIC[5];
|
||||
/* if enable_show_tabs_tws ==1 then use visible_tab visible_tws */
|
||||
extern int enable_show_tabs_tws;
|
||||
int edit_drop_hotkey_menu (WEdit *e, int key);
|
||||
void edit_menu_cmd (WEdit *e);
|
||||
int edit_drop_hotkey_menu (WEdit * e, int key);
|
||||
void edit_menu_cmd (WEdit * e);
|
||||
void edit_init_menu (struct WMenuBar *menubar);
|
||||
void menu_save_mode_cmd (void);
|
||||
int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch);
|
||||
int edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch);
|
||||
int edit_get_byte (WEdit * edit, long byte_index);
|
||||
char *edit_get_byte_ptr (WEdit * edit, long byte_index);
|
||||
char *edit_get_buf_ptr (WEdit * edit, long byte_index);
|
||||
|
@ -183,14 +188,14 @@ void edit_scroll_right (WEdit * edit, int i);
|
|||
void edit_scroll_left (WEdit * edit, int i);
|
||||
void edit_move_up (WEdit * edit, unsigned long i, int scroll);
|
||||
void edit_move_down (WEdit * edit, unsigned long i, int scroll);
|
||||
void edit_move_to_prev_col (WEdit *edit, long p);
|
||||
void edit_move_to_prev_col (WEdit * edit, long p);
|
||||
int edit_get_col (WEdit * edit);
|
||||
long edit_bol (WEdit * edit, long current);
|
||||
long edit_eol (WEdit * edit, long current);
|
||||
void edit_update_curs_row (WEdit * edit);
|
||||
void edit_update_curs_col (WEdit * edit);
|
||||
void edit_find_bracket (WEdit * edit);
|
||||
int edit_reload_line (WEdit *edit, const char *filename, long line);
|
||||
int edit_reload_line (WEdit * edit, const char *filename, long line);
|
||||
|
||||
void edit_block_copy_cmd (WEdit * edit);
|
||||
void edit_block_move_cmd (WEdit * edit);
|
||||
|
@ -210,13 +215,12 @@ long edit_write_stream (WEdit * edit, FILE * f);
|
|||
char *edit_get_write_filter (const char *writename, const char *filename);
|
||||
int edit_save_confirm_cmd (WEdit * edit);
|
||||
int edit_save_as_cmd (WEdit * edit);
|
||||
WEdit *edit_init (WEdit *edit, int lines, int columns,
|
||||
const char *filename, long line);
|
||||
WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, long line);
|
||||
int edit_clean (WEdit * edit);
|
||||
int edit_ok_to_exit (WEdit *edit);
|
||||
int edit_ok_to_exit (WEdit * edit);
|
||||
int edit_renew (WEdit * edit);
|
||||
int edit_new_cmd (WEdit * edit);
|
||||
int edit_reload (WEdit *edit, const char *filename);
|
||||
int edit_reload (WEdit * edit, const char *filename);
|
||||
int edit_load_cmd (WEdit * edit, edit_current_file_t what);
|
||||
void edit_mark_cmd (WEdit * edit, int unmark);
|
||||
void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);
|
||||
|
@ -224,7 +228,7 @@ void edit_push_markers (WEdit * edit);
|
|||
void edit_replace_cmd (WEdit * edit, int again);
|
||||
void edit_search_cmd (WEdit * edit, int again);
|
||||
void edit_complete_word_cmd (WEdit * edit);
|
||||
void edit_get_match_keyword_cmd (WEdit *edit);
|
||||
void edit_get_match_keyword_cmd (WEdit * edit);
|
||||
int edit_save_block (WEdit * edit, const char *filename, long start, long finish);
|
||||
int edit_save_block_cmd (WEdit * edit);
|
||||
int edit_insert_file_cmd (WEdit * edit);
|
||||
|
@ -239,8 +243,7 @@ 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_status (WEdit * edit);
|
||||
void edit_execute_key_command (WEdit *edit, unsigned long command,
|
||||
int char_for_insertion);
|
||||
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
|
||||
void edit_update_screen (WEdit * edit);
|
||||
int edit_print_string (WEdit * e, const char *s);
|
||||
void edit_move_to_line (WEdit * e, long line);
|
||||
|
@ -258,20 +261,19 @@ int edit_copy_to_X_buf_cmd (WEdit * edit);
|
|||
int edit_cut_to_X_buf_cmd (WEdit * edit);
|
||||
void edit_paste_from_X_buf_cmd (WEdit * edit);
|
||||
|
||||
void edit_select_codepage_cmd (WEdit *edit);
|
||||
void edit_insert_literal_cmd (WEdit *edit);
|
||||
void edit_execute_macro_cmd (WEdit *edit);
|
||||
void edit_begin_end_macro_cmd(WEdit *edit);
|
||||
void edit_select_codepage_cmd (WEdit * edit);
|
||||
void edit_insert_literal_cmd (WEdit * edit);
|
||||
void edit_execute_macro_cmd (WEdit * edit);
|
||||
void edit_begin_end_macro_cmd (WEdit * edit);
|
||||
|
||||
void edit_paste_from_history (WEdit *edit);
|
||||
void edit_paste_from_history (WEdit * edit);
|
||||
|
||||
void edit_set_filename (WEdit *edit, const char *name);
|
||||
void edit_set_filename (WEdit * edit, const char *name);
|
||||
|
||||
void edit_load_syntax (WEdit * edit, char ***pnames, const char *type);
|
||||
void edit_free_syntax_rules (WEdit * edit);
|
||||
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color);
|
||||
|
||||
|
||||
void book_mark_insert (WEdit * edit, int line, int c);
|
||||
int book_mark_query_color (WEdit * edit, int line, int c);
|
||||
int book_mark_query_all (WEdit * edit, int line, int *c);
|
||||
|
@ -281,16 +283,16 @@ void book_mark_flush (WEdit * edit, int c);
|
|||
void book_mark_inc (WEdit * edit, int line);
|
||||
void book_mark_dec (WEdit * edit, int line);
|
||||
|
||||
int line_is_blank (WEdit *edit, long line);
|
||||
int edit_indent_width (WEdit *edit, long p);
|
||||
void edit_insert_indent (WEdit *edit, int indent);
|
||||
void edit_options_dialog (void);
|
||||
void edit_syntax_dialog (void);
|
||||
void edit_mail_dialog (WEdit *edit);
|
||||
void format_paragraph (WEdit *edit, int force);
|
||||
int line_is_blank (WEdit * edit, long line);
|
||||
int edit_indent_width (WEdit * edit, long p);
|
||||
void edit_insert_indent (WEdit * edit, int indent);
|
||||
void edit_options_dialog (WEdit * edit);
|
||||
void edit_syntax_dialog (WEdit * edit, const char *current_syntax);
|
||||
void edit_mail_dialog (WEdit * edit);
|
||||
void format_paragraph (WEdit * edit, int force);
|
||||
|
||||
/* either command or char_for_insertion must be passed as -1 */
|
||||
void edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertion);
|
||||
void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion);
|
||||
|
||||
#define get_sys_error(s) (s)
|
||||
|
||||
|
@ -314,17 +316,15 @@ void edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertio
|
|||
extern edit_search_options_t edit_search_options;
|
||||
|
||||
extern int edit_stack_iterator;
|
||||
extern edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO];
|
||||
|
||||
extern WEdit *wedit;
|
||||
extern struct WMenuBar *edit_menubar;
|
||||
extern edit_stack_type edit_history_moveto[MAX_HISTORY_MOVETO];
|
||||
|
||||
extern const global_keymap_t *editor_map;
|
||||
extern const global_keymap_t *editor_x_map;
|
||||
|
||||
extern int option_line_state_width;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
EDIT_QUICK_SAVE = 0,
|
||||
EDIT_SAFE_SAVE,
|
||||
EDIT_DO_BACKUP
|
||||
|
@ -332,7 +332,6 @@ typedef enum {
|
|||
|
||||
extern int option_max_undo;
|
||||
extern int option_auto_syntax;
|
||||
extern char *option_syntax_type;
|
||||
|
||||
extern int option_edit_right_extreme;
|
||||
extern int option_edit_left_extreme;
|
||||
|
@ -344,4 +343,4 @@ extern int search_create_bookmark;
|
|||
|
||||
extern int column_highlighting;
|
||||
|
||||
#endif /* MC_EDIT_IMPL_H */
|
||||
#endif /* MC_EDIT_IMPL_H */
|
||||
|
|
|
@ -934,7 +934,7 @@ edit_init (WEdit * edit, int lines, int columns, const char *filename, long line
|
|||
edit->loading_done = 1;
|
||||
edit->modified = 0;
|
||||
edit->locked = 0;
|
||||
edit_load_syntax (edit, 0, 0);
|
||||
edit_load_syntax (edit, NULL, NULL);
|
||||
{
|
||||
int color;
|
||||
edit_get_syntax_color (edit, -1, &color);
|
||||
|
@ -1629,8 +1629,8 @@ edit_cursor_move (WEdit * edit, long increment)
|
|||
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE -
|
||||
(edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c;
|
||||
edit->curs2++;
|
||||
c = edit->
|
||||
buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE];
|
||||
c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 -
|
||||
1) & M_EDIT_BUF_SIZE];
|
||||
if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE))
|
||||
{
|
||||
g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
|
||||
|
@ -1938,9 +1938,8 @@ edit_move_to_prev_col (WEdit * edit, long p)
|
|||
|
||||
if (option_cursor_beyond_eol)
|
||||
{
|
||||
long line_len =
|
||||
edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
|
||||
edit_eol (edit, edit->curs1));
|
||||
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
|
||||
edit_eol (edit, edit->curs1));
|
||||
|
||||
if (line_len < prev + edit->over_col)
|
||||
{
|
||||
|
@ -2953,7 +2952,8 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
if (edit->overwrite)
|
||||
{
|
||||
/* remove char only one time, after input first byte, multibyte chars */
|
||||
if ((!utf8_display || edit->charpoint == 0) && edit_get_byte (edit, edit->curs1) != '\n')
|
||||
if ((!utf8_display || edit->charpoint == 0)
|
||||
&& edit_get_byte (edit, edit->curs1) != '\n')
|
||||
edit_delete (edit, 0);
|
||||
}
|
||||
if (option_cursor_beyond_eol && edit->over_col > 0)
|
||||
|
@ -3457,7 +3457,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
edit_load_cmd (edit, EDIT_FILE_SYNTAX);
|
||||
break;
|
||||
case CK_Choose_Syntax:
|
||||
edit_syntax_dialog ();
|
||||
edit_syntax_dialog (edit, edit->syntax_type);
|
||||
break;
|
||||
|
||||
case CK_Load_Menu_File:
|
||||
|
@ -3466,7 +3466,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
|
||||
case CK_Toggle_Syntax:
|
||||
if ((option_syntax_highlighting ^= 1) == 1)
|
||||
edit_load_syntax (edit, NULL, option_syntax_type);
|
||||
edit_load_syntax (edit, NULL, edit->syntax_type);
|
||||
edit->force |= REDRAW_PAGE;
|
||||
break;
|
||||
|
||||
|
@ -3527,7 +3527,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
learn_keys ();
|
||||
break;
|
||||
case CK_Edit_Options:
|
||||
edit_options_dialog ();
|
||||
edit_options_dialog (edit);
|
||||
break;
|
||||
case CK_Edit_Save_Mode:
|
||||
menu_save_mode_cmd ();
|
||||
|
|
|
@ -661,7 +661,7 @@ edit_save_as_cmd (WEdit * edit)
|
|||
edit->modified = 0;
|
||||
edit->delete_file = 0;
|
||||
if (different_filename)
|
||||
edit_load_syntax (edit, NULL, option_syntax_type);
|
||||
edit_load_syntax (edit, NULL, edit->syntax_type);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 1;
|
||||
default:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Source: editor menu definitions and initialisation
|
||||
|
@ -41,12 +41,12 @@
|
|||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/tty/tty.h" /* KEY_F */
|
||||
#include "lib/tty/key.h" /* XCTRL */
|
||||
#include "lib/tty/tty.h" /* KEY_F */
|
||||
#include "lib/tty/key.h" /* XCTRL */
|
||||
|
||||
#include "src/menu.h" /* menu_entry */
|
||||
#include "src/main.h" /* drop_menus */
|
||||
#include "src/dialog.h" /* cb_ret_t */
|
||||
#include "src/menu.h" /* menu_entry */
|
||||
#include "src/main.h" /* drop_menus */
|
||||
#include "src/dialog.h" /* cb_ret_t */
|
||||
#include "src/cmddef.h"
|
||||
|
||||
#include "edit-impl.h"
|
||||
|
@ -57,20 +57,20 @@ create_file_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Open file..."), CK_Load));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&New"), CK_New));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Open file..."), CK_Load));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&New"), CK_New));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Save"), CK_Save));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Save &as..."), CK_Save_As));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Save"), CK_Save));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Save &as..."), CK_Save_As));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Insert file..."), CK_Insert_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Insert file..."), CK_Insert_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Cop&y to file..."), CK_Save_Block));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&User menu..."), CK_User_Menu));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&User menu..."), CK_User_Menu));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("A&bout..."), CK_About));
|
||||
entries = g_list_append (entries, menu_entry_create (_("A&bout..."), CK_About));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Quit"), CK_Quit));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Quit"), CK_Quit));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -80,25 +80,25 @@ create_edit_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Undo"), CK_Undo));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Undo"), CK_Undo));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Toggle ins/overw"), CK_Toggle_Insert));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Toggle ins/overw"), CK_Toggle_Insert));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("To&ggle mark"), CK_Mark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Mark columns"), CK_Column_Mark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Mark &all"), CK_Mark_All));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Unmar&k"), CK_Unmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("To&ggle mark"), CK_Mark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Mark columns"), CK_Column_Mark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Mark &all"), CK_Mark_All));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Unmar&k"), CK_Unmark));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("Cop&y"), CK_Copy));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Mo&ve"), CK_Move));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Delete"), CK_Remove));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Cop&y"), CK_Copy));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Mo&ve"), CK_Move));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Delete"), CK_Remove));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("Co&py to clipfile"), CK_XStore));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Cut to clipfile"), CK_XCut));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Co&py to clipfile"), CK_XStore));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Cut to clipfile"), CK_XCut));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Pa&ste from clipfile"), CK_XPaste));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Beginning"), CK_Beginning_Of_Text));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&End"), CK_End_Of_Text));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Beginning"), CK_Beginning_Of_Text));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&End"), CK_End_Of_Text));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -108,14 +108,15 @@ create_search_replace_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Search..."), CK_Find));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Search &again"), CK_Find_Again));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Replace..."), CK_Replace));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Search..."), CK_Find));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Search &again"), CK_Find_Again));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Replace..."), CK_Replace));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Toggle bookmark"), CK_Toggle_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Next bookmark"), CK_Next_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Prev bookmark"), CK_Prev_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Flush bookmark"), CK_Flush_Bookmarks));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("&Toggle bookmark"), CK_Toggle_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Next bookmark"), CK_Next_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Prev bookmark"), CK_Prev_Bookmark));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Flush bookmark"), CK_Flush_Bookmarks));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -125,27 +126,38 @@ create_command_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Go to line..."), CK_Goto));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Toggle line state"), CK_Toggle_Line_State));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Go to matching &bracket"), CK_Match_Bracket));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Go to line..."), CK_Goto));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("&Toggle line state"), CK_Toggle_Line_State));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("Go to matching &bracket"), CK_Match_Bracket));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Find declaration"), CK_Find_Definition));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Back from &declaration"), CK_Load_Prev_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("For&ward to declaration"), CK_Load_Next_File));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("&Find declaration"), CK_Find_Definition));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("Back from &declaration"), CK_Load_Prev_File));
|
||||
entries =
|
||||
g_list_append (entries,
|
||||
menu_entry_create (_("For&ward to declaration"), CK_Load_Next_File));
|
||||
#ifdef HAVE_CHARSET
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("Encod&ing..."), CK_SelectCodepage));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Encod&ing..."), CK_SelectCodepage));
|
||||
#endif
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Refresh screen"), CK_Refresh));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Refresh screen"), CK_Refresh));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Start record macro"), CK_Begin_Record_Macro));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Finis&h record macro..."), CK_End_Record_Macro));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Execute macro..."), CK_Execute_Macro));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Delete macr&o..."), CK_Delete_Macro));
|
||||
entries =
|
||||
g_list_append (entries,
|
||||
menu_entry_create (_("&Start record macro"), CK_Begin_Record_Macro));
|
||||
entries =
|
||||
g_list_append (entries,
|
||||
menu_entry_create (_("Finis&h record macro..."), CK_End_Record_Macro));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Execute macro..."), CK_Execute_Macro));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Delete macr&o..."), CK_Delete_Macro));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("'ispell' s&pell check"), CK_Pipe_Block (1)));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Mail..."), CK_Mail));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("'ispell' s&pell check"), CK_Pipe_Block (1)));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Mail..."), CK_Mail));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -155,13 +167,16 @@ create_format_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("Insert &literal..."), CK_Insert_Literal));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Insert &date/time"), CK_Date));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("Insert &literal..."), CK_Insert_Literal));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Insert &date/time"), CK_Date));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Format paragraph"), CK_Paragraph_Format));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Sort..."), CK_Sort));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Paste output of..."), CK_ExtCmd));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&External formatter"), CK_Pipe_Block (0)));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("&Format paragraph"), CK_Paragraph_Format));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Sort..."), CK_Sort));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Paste output of..."), CK_ExtCmd));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("&External formatter"), CK_Pipe_Block (0)));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -171,15 +186,16 @@ create_options_menu (void)
|
|||
{
|
||||
GList *entries = NULL;
|
||||
|
||||
entries = g_list_append (entries, menu_entry_create (_("&General... "), CK_Edit_Options));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Save &mode..."), CK_Edit_Save_Mode));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Syntax &highlighting..."), CK_Choose_Syntax));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&General... "), CK_Edit_Options));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Save &mode..."), CK_Edit_Save_Mode));
|
||||
entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
|
||||
entries =
|
||||
g_list_append (entries, menu_entry_create (_("Syntax &highlighting..."), CK_Choose_Syntax));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("S&yntax file"), CK_Load_Syntax_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Menu file"), CK_Load_Menu_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("S&yntax file"), CK_Load_Syntax_File));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Menu file"), CK_Load_Menu_File));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd));
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -187,59 +203,74 @@ create_options_menu (void)
|
|||
void
|
||||
edit_init_menu (struct WMenuBar *menubar)
|
||||
{
|
||||
menubar_add_menu (menubar, create_menu (_("&File"), create_file_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar, create_menu (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar, create_menu (_("&Search"), create_search_replace_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar, create_menu (_("&Command"), create_command_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar, create_menu (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar, create_menu (_("&Options"), create_options_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("&File"), create_file_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("&Search"), create_search_replace_menu (),
|
||||
"[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("&Command"), create_command_menu (),
|
||||
"[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
|
||||
menubar_add_menu (menubar,
|
||||
create_menu (_("&Options"), create_options_menu (),
|
||||
"[Internal File Editor]"));
|
||||
}
|
||||
|
||||
static void
|
||||
edit_drop_menu_cmd (WEdit *e, int which)
|
||||
edit_drop_menu_cmd (WEdit * e, int which)
|
||||
{
|
||||
if (!edit_menubar->is_active) {
|
||||
edit_menubar->is_active = TRUE;
|
||||
edit_menubar->is_dropped = (drop_menus != 0);
|
||||
if (which >= 0)
|
||||
edit_menubar->selected = which;
|
||||
WMenuBar *menubar;
|
||||
|
||||
edit_menubar->previous_widget = e->widget.parent->current->dlg_id;
|
||||
dlg_select_widget (edit_menubar);
|
||||
menubar = find_menubar (e->widget.parent);
|
||||
|
||||
if (!menubar->is_active)
|
||||
{
|
||||
menubar->is_active = TRUE;
|
||||
menubar->is_dropped = (drop_menus != 0);
|
||||
if (which >= 0)
|
||||
menubar->selected = which;
|
||||
|
||||
menubar->previous_widget = e->widget.parent->current->dlg_id;
|
||||
dlg_select_widget (menubar);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edit_menu_cmd (WEdit *e)
|
||||
edit_menu_cmd (WEdit * e)
|
||||
{
|
||||
edit_drop_menu_cmd (e, -1);
|
||||
}
|
||||
|
||||
int
|
||||
edit_drop_hotkey_menu (WEdit *e, int key)
|
||||
edit_drop_hotkey_menu (WEdit * e, int key)
|
||||
{
|
||||
int m = 0;
|
||||
switch (key) {
|
||||
switch (key)
|
||||
{
|
||||
case ALT ('f'):
|
||||
m = 0;
|
||||
break;
|
||||
m = 0;
|
||||
break;
|
||||
case ALT ('e'):
|
||||
m = 1;
|
||||
break;
|
||||
m = 1;
|
||||
break;
|
||||
case ALT ('s'):
|
||||
m = 2;
|
||||
break;
|
||||
m = 2;
|
||||
break;
|
||||
case ALT ('c'):
|
||||
m = 3;
|
||||
break;
|
||||
m = 3;
|
||||
break;
|
||||
case ALT ('m'):
|
||||
m = 4;
|
||||
break;
|
||||
m = 4;
|
||||
break;
|
||||
case ALT ('o'):
|
||||
m = 5;
|
||||
break;
|
||||
m = 5;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
edit_drop_menu_cmd (e, m);
|
||||
|
|
|
@ -62,7 +62,7 @@ i18n_translate_array (const char *array[])
|
|||
#endif /* ENABLE_NLS */
|
||||
|
||||
void
|
||||
edit_options_dialog (void)
|
||||
edit_options_dialog (WEdit *edit)
|
||||
{
|
||||
char wrap_length[16], tab_spacing[16], *p, *q;
|
||||
int wrap_mode = 0;
|
||||
|
@ -139,7 +139,7 @@ edit_options_dialog (void)
|
|||
old_syntax_hl = option_syntax_highlighting;
|
||||
|
||||
if (!option_cursor_beyond_eol)
|
||||
wedit->over_col = 0;
|
||||
edit->over_col = 0;
|
||||
|
||||
if (p) {
|
||||
option_word_wrap_line_length = atoi (p);
|
||||
|
@ -165,5 +165,5 @@ edit_options_dialog (void)
|
|||
|
||||
/* Load or unload syntax rules if the option has changed */
|
||||
if (option_syntax_highlighting != old_syntax_hl)
|
||||
edit_load_syntax (wedit, NULL, option_syntax_type);
|
||||
edit_load_syntax (edit, NULL, edit->syntax_type);
|
||||
}
|
||||
|
|
|
@ -41,20 +41,17 @@
|
|||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
||||
#include "lib/tty/key.h" /* is_idle() */
|
||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
||||
#include "lib/tty/key.h" /* is_idle() */
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
|
||||
#include "src/dialog.h"
|
||||
#include "src/widget.h" /* ButtonBar */
|
||||
#include "src/menu.h" /* menubar_new() */
|
||||
#include "src/widget.h" /* ButtonBar */
|
||||
#include "src/menu.h" /* menubar_new() */
|
||||
#include "src/cmddef.h"
|
||||
|
||||
WEdit *wedit;
|
||||
struct WMenuBar *edit_menubar;
|
||||
|
||||
int column_highlighting = 0;
|
||||
|
||||
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
|
||||
|
@ -67,85 +64,99 @@ edit_get_shortcut (unsigned long command)
|
|||
|
||||
shortcut = lookup_keymap_shortcut (editor_map, command);
|
||||
if (shortcut != NULL)
|
||||
return g_strdup (shortcut);
|
||||
return g_strdup (shortcut);
|
||||
|
||||
ext_map = lookup_keymap_shortcut (editor_map, CK_Ext_Mode);
|
||||
if (ext_map != NULL)
|
||||
shortcut = lookup_keymap_shortcut (editor_x_map, command);
|
||||
shortcut = lookup_keymap_shortcut (editor_x_map, command);
|
||||
if (shortcut != NULL)
|
||||
return g_strdup_printf ("%s %s", ext_map, shortcut);
|
||||
return g_strdup_printf ("%s %s", ext_map, shortcut);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
edit_event (Gpm_Event *event, void *data)
|
||||
edit_event (Gpm_Event * event, void *data)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
/* Unknown event type */
|
||||
if (!(event->type & (GPM_DOWN | GPM_DRAG | GPM_UP)))
|
||||
return MOU_NORMAL;
|
||||
return MOU_NORMAL;
|
||||
|
||||
/* rest of the upper frame, the menu is invisible - call menu */
|
||||
if ((event->type & GPM_DOWN) && (event->y == 1))
|
||||
return edit_menubar->widget.mouse (event, edit_menubar);
|
||||
{
|
||||
WMenuBar *menubar;
|
||||
|
||||
menubar = find_menubar (edit->widget.parent);
|
||||
|
||||
return menubar->widget.mouse (event, menubar);
|
||||
}
|
||||
|
||||
edit_update_curs_row (edit);
|
||||
edit_update_curs_col (edit);
|
||||
|
||||
/* Outside editor window */
|
||||
if (event->y <= 1 || event->x <= 0
|
||||
|| event->x > edit->num_widget_columns
|
||||
|| event->y > edit->num_widget_lines + 1)
|
||||
return MOU_NORMAL;
|
||||
|| event->x > edit->num_widget_columns || event->y > edit->num_widget_lines + 1)
|
||||
return MOU_NORMAL;
|
||||
|
||||
/* Wheel events */
|
||||
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
|
||||
edit_move_up (edit, 2, 1);
|
||||
goto update;
|
||||
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN))
|
||||
{
|
||||
edit_move_up (edit, 2, 1);
|
||||
goto update;
|
||||
}
|
||||
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
|
||||
edit_move_down (edit, 2, 1);
|
||||
goto update;
|
||||
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN))
|
||||
{
|
||||
edit_move_down (edit, 2, 1);
|
||||
goto update;
|
||||
}
|
||||
|
||||
/* A lone up mustn't do anything */
|
||||
if (edit->mark2 != -1 && event->type & (GPM_UP | GPM_DRAG))
|
||||
return MOU_NORMAL;
|
||||
return MOU_NORMAL;
|
||||
|
||||
if (event->type & (GPM_DOWN | GPM_UP))
|
||||
edit_push_key_press (edit);
|
||||
edit_push_key_press (edit);
|
||||
|
||||
if (option_cursor_beyond_eol) {
|
||||
if (option_cursor_beyond_eol)
|
||||
{
|
||||
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
|
||||
edit_eol(edit, edit->curs1));
|
||||
edit_eol (edit, edit->curs1));
|
||||
|
||||
if ( event->x > line_len ) {
|
||||
if (event->x > line_len)
|
||||
{
|
||||
edit->over_col = event->x - line_len - edit->start_col - option_line_state_width - 1;
|
||||
edit->prev_col = line_len;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
edit->over_col = 0;
|
||||
edit->prev_col = event->x - option_line_state_width - edit->start_col - 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
edit->prev_col = event->x - edit->start_col - option_line_state_width - 1;
|
||||
}
|
||||
|
||||
if (--event->y > (edit->curs_row + 1))
|
||||
edit_move_down (edit, event->y - (edit->curs_row + 1), 0);
|
||||
edit_move_down (edit, event->y - (edit->curs_row + 1), 0);
|
||||
else if (event->y < (edit->curs_row + 1))
|
||||
edit_move_up (edit, (edit->curs_row + 1) - event->y, 0);
|
||||
edit_move_up (edit, (edit->curs_row + 1) - event->y, 0);
|
||||
else
|
||||
edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1));
|
||||
edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1));
|
||||
|
||||
if (event->type & GPM_DOWN) {
|
||||
edit_mark_cmd (edit, 1); /* reset */
|
||||
edit->highlight = 0;
|
||||
if (event->type & GPM_DOWN)
|
||||
{
|
||||
edit_mark_cmd (edit, 1); /* reset */
|
||||
edit->highlight = 0;
|
||||
}
|
||||
|
||||
if (!(event->type & GPM_DRAG))
|
||||
edit_mark_cmd (edit, 0);
|
||||
edit_mark_cmd (edit, 0);
|
||||
|
||||
update:
|
||||
edit_find_bracket (edit);
|
||||
|
@ -158,36 +169,36 @@ edit_event (Gpm_Event *event, void *data)
|
|||
}
|
||||
|
||||
static cb_ret_t
|
||||
edit_command_execute (WEdit *edit, unsigned long command)
|
||||
edit_command_execute (WEdit * edit, unsigned long command)
|
||||
{
|
||||
if (command == CK_Menu)
|
||||
edit_menu_cmd (edit);
|
||||
else {
|
||||
edit_execute_key_command (edit, command, -1);
|
||||
edit_update_screen (edit);
|
||||
edit_menu_cmd (edit);
|
||||
else
|
||||
{
|
||||
edit_execute_key_command (edit, command, -1);
|
||||
edit_update_screen (edit);
|
||||
}
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
static inline void
|
||||
edit_set_buttonbar (WEdit *edit, WButtonBar *bb)
|
||||
edit_set_buttonbar (WEdit * edit, WButtonBar * bb)
|
||||
{
|
||||
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 4, Q_("ButtonBar|Replac"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 5, Q_("ButtonBar|Copy"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 6, Q_("ButtonBar|Move"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 7, Q_("ButtonBar|Search"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 8, Q_("ButtonBar|Delete"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 9, Q_("ButtonBar|PullDn"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 10, Q_("ButtonBar|Quit"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 1, Q_ ("ButtonBar|Help"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 2, Q_ ("ButtonBar|Save"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 3, Q_ ("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 4, Q_ ("ButtonBar|Replac"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 5, Q_ ("ButtonBar|Copy"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 6, Q_ ("ButtonBar|Move"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 7, Q_ ("ButtonBar|Search"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 8, Q_ ("ButtonBar|Delete"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 9, Q_ ("ButtonBar|PullDn"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 10, Q_ ("ButtonBar|Quit"), editor_map, (Widget *) edit);
|
||||
}
|
||||
|
||||
/* Callback for the edit dialog */
|
||||
static cb_ret_t
|
||||
edit_dialog_callback (Dlg_head *h, Widget *sender,
|
||||
dlg_msg_t msg, int parm, void *data)
|
||||
edit_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WEdit *edit;
|
||||
WMenuBar *menubar;
|
||||
|
@ -197,32 +208,33 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
|
|||
menubar = find_menubar (h);
|
||||
buttonbar = find_buttonbar (h);
|
||||
|
||||
switch (msg) {
|
||||
switch (msg)
|
||||
{
|
||||
case DLG_INIT:
|
||||
edit_set_buttonbar (edit, buttonbar);
|
||||
return MSG_HANDLED;
|
||||
edit_set_buttonbar (edit, buttonbar);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case DLG_RESIZE:
|
||||
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
|
||||
widget_set_size (&buttonbar->widget , LINES - 1, 0, 1, COLS);
|
||||
widget_set_size (&menubar->widget, 0, 0, 1, COLS);
|
||||
menubar_arrange (menubar);
|
||||
return MSG_HANDLED;
|
||||
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
|
||||
widget_set_size (&buttonbar->widget, LINES - 1, 0, 1, COLS);
|
||||
widget_set_size (&menubar->widget, 0, 0, 1, COLS);
|
||||
menubar_arrange (menubar);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case DLG_ACTION:
|
||||
if (sender == (Widget *) menubar)
|
||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||
if (sender == (Widget *) buttonbar)
|
||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||
return MSG_HANDLED;
|
||||
if (sender == (Widget *) menubar)
|
||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||
if (sender == (Widget *) buttonbar)
|
||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case DLG_VALIDATE:
|
||||
if (!edit_ok_to_exit (edit))
|
||||
h->running = 1;
|
||||
return MSG_HANDLED;
|
||||
if (!edit_ok_to_exit (edit))
|
||||
h->running = 1;
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return default_dlg_callback (h, sender, msg, parm, data);
|
||||
return default_dlg_callback (h, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,30 +243,32 @@ edit_file (const char *_file, int line)
|
|||
{
|
||||
static gboolean made_directory = FALSE;
|
||||
Dlg_head *edit_dlg;
|
||||
WEdit *wedit;
|
||||
WMenuBar *menubar;
|
||||
|
||||
if (!made_directory) {
|
||||
char *dir = concat_dir_and_file (home_dir, EDIT_DIR);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
if (!made_directory)
|
||||
{
|
||||
char *dir = concat_dir_and_file (home_dir, EDIT_DIR);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
}
|
||||
|
||||
wedit = edit_init (NULL, LINES - 2, COLS, _file, line);
|
||||
|
||||
if (wedit == NULL)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
/* Create a new dialog and add it widgets to it */
|
||||
edit_dlg =
|
||||
create_dlg (0, 0, LINES, COLS, NULL, edit_dialog_callback,
|
||||
"[Internal File Editor]", NULL, DLG_WANT_TAB);
|
||||
create_dlg (0, 0, LINES, COLS, NULL, edit_dialog_callback,
|
||||
"[Internal File Editor]", NULL, DLG_WANT_TAB);
|
||||
|
||||
edit_dlg->get_shortcut = edit_get_shortcut;
|
||||
edit_menubar = menubar_new (0, 0, COLS, NULL);
|
||||
add_widget (edit_dlg, edit_menubar);
|
||||
edit_init_menu (edit_menubar);
|
||||
menubar = menubar_new (0, 0, COLS, NULL);
|
||||
add_widget (edit_dlg, menubar);
|
||||
edit_init_menu (menubar);
|
||||
|
||||
init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS,
|
||||
edit_callback, edit_event);
|
||||
init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS, edit_callback, edit_event);
|
||||
widget_want_cursor (wedit->widget, 1);
|
||||
|
||||
add_widget (edit_dlg, wedit);
|
||||
|
@ -269,7 +283,7 @@ edit_file (const char *_file, int line)
|
|||
}
|
||||
|
||||
const char *
|
||||
edit_get_file_name (const WEdit *edit)
|
||||
edit_get_file_name (const WEdit * edit)
|
||||
{
|
||||
return edit->filename;
|
||||
}
|
||||
|
@ -284,61 +298,65 @@ edit_update_screen (WEdit * e)
|
|||
|
||||
/* pop all events for this window for internal handling */
|
||||
if (!is_idle ())
|
||||
e->force |= REDRAW_PAGE;
|
||||
else {
|
||||
if (e->force & REDRAW_COMPLETELY)
|
||||
e->force |= REDRAW_PAGE;
|
||||
edit_render_keypress (e);
|
||||
e->force |= REDRAW_PAGE;
|
||||
else
|
||||
{
|
||||
if (e->force & REDRAW_COMPLETELY)
|
||||
e->force |= REDRAW_PAGE;
|
||||
edit_render_keypress (e);
|
||||
}
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
edit_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
edit_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WEdit *e = (WEdit *) w;
|
||||
|
||||
switch (msg) {
|
||||
switch (msg)
|
||||
{
|
||||
case WIDGET_DRAW:
|
||||
e->force |= REDRAW_COMPLETELY;
|
||||
e->num_widget_lines = LINES - 2;
|
||||
e->num_widget_columns = COLS;
|
||||
/* fallthrough */
|
||||
e->force |= REDRAW_COMPLETELY;
|
||||
e->num_widget_lines = LINES - 2;
|
||||
e->num_widget_columns = COLS;
|
||||
/* fallthrough */
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
edit_update_screen (e);
|
||||
return MSG_HANDLED;
|
||||
edit_update_screen (e);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_KEY:
|
||||
{
|
||||
int cmd, ch;
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
{
|
||||
int cmd, ch;
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
/* The user may override the access-keys for the menu bar. */
|
||||
if (edit_translate_key (e, parm, &cmd, &ch)) {
|
||||
edit_execute_key_command (e, cmd, ch);
|
||||
edit_update_screen (e);
|
||||
ret = MSG_HANDLED;
|
||||
} else if (edit_drop_hotkey_menu (e, parm))
|
||||
ret = MSG_HANDLED;
|
||||
/* The user may override the access-keys for the menu bar. */
|
||||
if (edit_translate_key (e, parm, &cmd, &ch))
|
||||
{
|
||||
edit_execute_key_command (e, cmd, ch);
|
||||
edit_update_screen (e);
|
||||
ret = MSG_HANDLED;
|
||||
}
|
||||
else if (edit_drop_hotkey_menu (e, parm))
|
||||
ret = MSG_HANDLED;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
case WIDGET_COMMAND:
|
||||
/* command from menubar or buttonbar */
|
||||
return edit_command_execute (e, parm);
|
||||
/* command from menubar or buttonbar */
|
||||
return edit_command_execute (e, parm);
|
||||
|
||||
case WIDGET_CURSOR:
|
||||
widget_move (&e->widget, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET,
|
||||
e->curs_col + e->start_col + e->over_col +
|
||||
EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width);
|
||||
return MSG_HANDLED;
|
||||
widget_move (&e->widget, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET,
|
||||
e->curs_col + e->start_col + e->over_col +
|
||||
EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
edit_clean (e);
|
||||
return MSG_HANDLED;
|
||||
edit_clean (e);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return default_proc (msg, parm);
|
||||
return default_proc (msg, parm);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ struct _syntax_marker
|
|||
|
||||
int option_syntax_highlighting = 1;
|
||||
int option_auto_syntax = 1;
|
||||
char *option_syntax_type = NULL;
|
||||
|
||||
static gint
|
||||
mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
||||
|
|
Loading…
Reference in New Issue