mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Added events for editor
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
bd2718e587
commit
619653620e
@ -18,6 +18,7 @@ libedit_la_SOURCES = \
|
||||
editmenu.c \
|
||||
editoptions.c \
|
||||
editwidget.c editwidget.h \
|
||||
event.c event.h \
|
||||
etags.c etags.h \
|
||||
format.c \
|
||||
macro.c macro.h \
|
||||
@ -27,6 +28,7 @@ if USE_ASPELL
|
||||
if HAVE_GMODULE
|
||||
libedit_la_SOURCES += \
|
||||
spell.c spell.h \
|
||||
spell_cmd.c \
|
||||
spell_dialogs.c spell_dialogs.h
|
||||
endif
|
||||
endif
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "editwidget.h"
|
||||
#include "event.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -93,12 +94,18 @@ exec_edit_syntax_dialog (const GPtrArray * names, const char *current_syntax)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
void
|
||||
edit_syntax_dialog (WEdit * edit)
|
||||
gboolean
|
||||
mc_editor_cmd_syntax_show_dialog (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
GPtrArray *names;
|
||||
int syntax;
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
|
||||
names = g_ptr_array_new ();
|
||||
|
||||
@ -143,6 +150,8 @@ edit_syntax_dialog (WEdit * edit)
|
||||
|
||||
g_ptr_array_foreach (names, (GFunc) g_free, NULL);
|
||||
g_ptr_array_free (names, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -115,6 +115,7 @@ typedef struct edit_stack_type
|
||||
|
||||
struct Widget;
|
||||
struct WMenuBar;
|
||||
struct edit_buffer_struct;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
@ -150,7 +151,7 @@ WEdit *find_editor (const WDialog * h);
|
||||
gboolean edit_widget_is_editor (const Widget * w);
|
||||
gboolean edit_drop_hotkey_menu (WDialog * h, int key);
|
||||
void edit_menu_cmd (WDialog * h);
|
||||
void user_menu (WEdit * edit, const char *menu_file, int selected_entry);
|
||||
void mc_editor_call_event_user_menu (WEdit * edit, const char *menu_file, int selected_entry);
|
||||
void edit_init_menu (struct WMenuBar *menubar);
|
||||
void edit_save_mode_cmd (void);
|
||||
off_t edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto);
|
||||
@ -170,10 +171,7 @@ void edit_find_bracket (WEdit * edit);
|
||||
gboolean edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line);
|
||||
void edit_set_codeset (WEdit * edit);
|
||||
|
||||
void edit_block_copy_cmd (WEdit * edit);
|
||||
void edit_block_move_cmd (WEdit * edit);
|
||||
int edit_block_delete_cmd (WEdit * edit);
|
||||
void edit_delete_line (WEdit * edit);
|
||||
int mc_editor_call_event_block_delete (WEdit * edit);
|
||||
|
||||
int edit_delete (WEdit * edit, gboolean byte_delete);
|
||||
int edit_backspace (WEdit * edit, gboolean byte_delete);
|
||||
@ -187,8 +185,7 @@ void edit_insert_ahead (WEdit * edit, int c);
|
||||
off_t edit_write_stream (WEdit * edit, FILE * f);
|
||||
char *edit_get_write_filter (const vfs_path_t * write_name_vpath,
|
||||
const vfs_path_t * filename_vpath);
|
||||
gboolean edit_save_confirm_cmd (WEdit * edit);
|
||||
gboolean edit_save_as_cmd (WEdit * edit);
|
||||
gboolean mc_editor_call_event_save_as (WEdit * edit);
|
||||
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols,
|
||||
const vfs_path_t * filename_vpath, long line);
|
||||
gboolean edit_clean (WEdit * edit);
|
||||
@ -202,28 +199,15 @@ void edit_mark_current_word_cmd (WEdit * edit);
|
||||
void edit_mark_current_line_cmd (WEdit * edit);
|
||||
void edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2);
|
||||
void edit_push_markers (WEdit * edit);
|
||||
void edit_replace_cmd (WEdit * edit, int again);
|
||||
void edit_search_cmd (WEdit * edit, gboolean again);
|
||||
mc_search_cbret_t edit_search_cmd_callback (const void *user_data, gsize char_offset,
|
||||
int *current_char);
|
||||
mc_search_cbret_t edit_search_update_callback (const void *user_data, gsize char_offset);
|
||||
|
||||
void edit_complete_word_cmd (WEdit * edit);
|
||||
void edit_get_match_keyword_cmd (WEdit * edit);
|
||||
|
||||
#ifdef HAVE_ASPELL
|
||||
int edit_suggest_current_word (WEdit * edit);
|
||||
void edit_spellcheck_file (WEdit * edit);
|
||||
void edit_set_spell_lang (void);
|
||||
#endif
|
||||
|
||||
gboolean edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish);
|
||||
gboolean edit_save_block_cmd (WEdit * edit);
|
||||
gboolean edit_insert_file_cmd (WEdit * edit);
|
||||
|
||||
off_t edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
|
||||
gboolean edit_load_back_cmd (WEdit * edit);
|
||||
gboolean edit_load_forward_cmd (WEdit * edit);
|
||||
void edit_block_process_cmd (WEdit * edit, int macro_number);
|
||||
void edit_refresh_cmd (void);
|
||||
void edit_syntax_onoff_cmd (WDialog * h);
|
||||
@ -231,28 +215,15 @@ void edit_show_tabs_tws_cmd (WDialog * h);
|
||||
void edit_show_margin_cmd (WDialog * h);
|
||||
void edit_show_numbers_cmd (WDialog * h);
|
||||
void edit_date_cmd (WEdit * edit);
|
||||
void edit_goto_cmd (WEdit * edit);
|
||||
gboolean eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark);
|
||||
void edit_status (WEdit * edit, gboolean active);
|
||||
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
|
||||
void edit_update_screen (WEdit * edit);
|
||||
void edit_save_size (WEdit * edit);
|
||||
gboolean edit_handle_move_resize (WEdit * edit, unsigned long command);
|
||||
void edit_toggle_fullscreen (WEdit * edit);
|
||||
void edit_move_to_line (WEdit * e, long line);
|
||||
void edit_move_display (WEdit * e, long line);
|
||||
void edit_word_wrap (WEdit * edit);
|
||||
int edit_sort_cmd (WEdit * edit);
|
||||
int edit_ext_cmd (WEdit * edit);
|
||||
|
||||
gboolean edit_copy_to_X_buf_cmd (WEdit * edit);
|
||||
gboolean edit_cut_to_X_buf_cmd (WEdit * edit);
|
||||
gboolean edit_paste_from_X_buf_cmd (WEdit * edit);
|
||||
|
||||
void edit_select_codepage_cmd (WEdit * edit);
|
||||
void edit_insert_literal_cmd (WEdit * edit);
|
||||
|
||||
void edit_paste_from_history (WEdit * edit);
|
||||
|
||||
void edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath);
|
||||
|
||||
@ -273,9 +244,6 @@ void book_mark_restore (WEdit * edit, int color);
|
||||
gboolean edit_line_is_blank (WEdit * edit, long line);
|
||||
gboolean is_break_char (char c);
|
||||
void edit_options_dialog (WDialog * h);
|
||||
void edit_syntax_dialog (WEdit * edit);
|
||||
void edit_mail_dialog (WEdit * edit);
|
||||
void format_paragraph (WEdit * edit, gboolean 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);
|
||||
|
2108
src/editor/edit.c
2108
src/editor/edit.c
File diff suppressed because it is too large
Load Diff
@ -63,8 +63,8 @@ extern int show_right_margin;
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* used in main() */
|
||||
void edit_stack_init (void);
|
||||
void edit_stack_free (void);
|
||||
void mc_editor_init (GError ** error);
|
||||
void mc_editor_deinit (GError ** error);
|
||||
|
||||
gboolean edit_file (const vfs_path_t * file_vpath, long line);
|
||||
gboolean edit_files (const GList * files);
|
||||
|
1054
src/editor/editcmd.c
1054
src/editor/editcmd.c
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,7 @@
|
||||
#include "spell.h"
|
||||
#endif
|
||||
#include "macro.h"
|
||||
#include "event.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -446,7 +447,7 @@ edit_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (local.x == w->cols - dx - 4)
|
||||
{
|
||||
edit_toggle_fullscreen (edit);
|
||||
mc_event_raise (MCEVENT_GROUP_EDITOR, "toggle_fullscreen", edit, NULL);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
@ -594,7 +595,7 @@ edit_event (Gpm_Event * event, void *data)
|
||||
else if (y == w->y && (event->type & (GPM_DOUBLE | GPM_UP)) == (GPM_DOUBLE | GPM_UP))
|
||||
{
|
||||
/* double click on top line (toggle fullscreen) */
|
||||
edit_toggle_fullscreen (edit);
|
||||
mc_event_raise (MCEVENT_GROUP_EDITOR, "toggle_fullscreen", edit, NULL);
|
||||
edit->drag_state = MCEDIT_DRAG_NORMAL;
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
edit_update_screen (edit);
|
||||
@ -692,7 +693,7 @@ edit_dialog_event (Gpm_Event * event, void *data)
|
||||
|
||||
/* Handle buttons */
|
||||
if (x <= 2)
|
||||
edit_toggle_fullscreen (e);
|
||||
mc_event_raise (MCEVENT_GROUP_EDITOR, "toggle_fullscreen", e, NULL);
|
||||
else
|
||||
send_message (h, NULL, MSG_ACTION, CK_Close, NULL);
|
||||
|
||||
@ -1466,15 +1467,21 @@ edit_handle_move_resize (WEdit * edit, unsigned long command)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
/**
|
||||
* Toggle window fuulscreen mode.
|
||||
*
|
||||
* @param edit editor object
|
||||
*/
|
||||
|
||||
void
|
||||
edit_toggle_fullscreen (WEdit * edit)
|
||||
gboolean
|
||||
mc_editor_cmd_toggle_fullscreen (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
edit->fullscreen = !edit->fullscreen;
|
||||
edit->force = REDRAW_COMPLETELY;
|
||||
|
||||
@ -1490,6 +1497,8 @@ edit_toggle_fullscreen (WEdit * edit)
|
||||
edit->force |= REDRAW_PAGE;
|
||||
edit_update_screen (edit);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -111,6 +111,7 @@ struct WEdit
|
||||
unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
|
||||
unsigned int highlight:1; /* There is a selected block */
|
||||
unsigned int column_highlight:1;
|
||||
unsigned int is_cursor_moved:1;
|
||||
unsigned int fullscreen:1; /* Is window fullscreen or not */
|
||||
long prev_col; /* recent column position of the cursor - used when moving
|
||||
up or down past lines that are shorter than the current line */
|
||||
|
161
src/editor/event.c
Normal file
161
src/editor/event.c
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
Editor's events definitions.
|
||||
|
||||
Copyright (C) 2012-2014
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2014
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "event.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_editor_init_events (GError ** error)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
event_init_group_t core_group_events[] =
|
||||
{
|
||||
{"backspace", mc_editor_cmd_backspace, NULL},
|
||||
{"delete", mc_editor_cmd_delete, NULL},
|
||||
{"delete_word_left", mc_editor_cmd_delete_word, (void *) TO_LEFT},
|
||||
{"delete_word_right", mc_editor_cmd_delete_word, (void *) TO_RIGHT},
|
||||
|
||||
{"delete_line", mc_editor_cmd_delete_line, (void *) NONE},
|
||||
{"delete_line_to_begin", mc_editor_cmd_delete_line, (void *) TO_LINE_BEGIN},
|
||||
{"delete_line_to_end", mc_editor_cmd_delete_line, (void *) TO_LINE_END},
|
||||
|
||||
{"enter", mc_editor_cmd_enter, NULL},
|
||||
{"insert_char_raw", mc_editor_cmd_insert_char_raw, NULL},
|
||||
{"insert_char", mc_editor_cmd_insert_char, NULL},
|
||||
{"undo", mc_editor_cmd_undo, NULL},
|
||||
{"redo", mc_editor_cmd_redo, NULL},
|
||||
{"toggle_fullscreen", mc_editor_cmd_toggle_fullscreen, NULL},
|
||||
{"tab", mc_editor_cmd_tab, NULL},
|
||||
{"switch_insert_overwrite", mc_editor_cmd_switch_insert_overwrite, NULL},
|
||||
|
||||
{"move_cursor", mc_editor_cmd_move_cursor, NULL},
|
||||
|
||||
{"mark", mc_editor_cmd_mark, NULL},
|
||||
{"mark_column", mc_editor_cmd_mark_column, NULL},
|
||||
{"mark_all", mc_editor_cmd_mark_all, NULL},
|
||||
{"unmark", mc_editor_cmd_unmark, NULL},
|
||||
{"mark_word", mc_editor_cmd_mark, NULL},
|
||||
{"mark_line", mc_editor_cmd_mark, NULL},
|
||||
|
||||
{"bookmark_toggle", mc_editor_cmd_bookmark_toggle, NULL},
|
||||
{"bookmark_flush", mc_editor_cmd_bookmark_flush, NULL},
|
||||
{"bookmark_next", mc_editor_cmd_bookmark_next, NULL},
|
||||
{"bookmark_prev", mc_editor_cmd_bookmark_prev, NULL},
|
||||
|
||||
{"block_copy", mc_editor_cmd_block_copy, NULL},
|
||||
{"block_delete", mc_editor_cmd_block_delete, NULL},
|
||||
{"block_move", mc_editor_cmd_block_move, NULL},
|
||||
{"block_move_to_left", mc_editor_cmd_block_move_to_left, NULL},
|
||||
{"block_move_to_right", mc_editor_cmd_block_move_to_right, NULL},
|
||||
|
||||
{"ext_clip_copy", mc_editor_cmd_ext_clip_copy, NULL},
|
||||
{"ext_clip_cut", mc_editor_cmd_ext_clip_cut, NULL},
|
||||
{"ext_clip_paste", mc_editor_cmd_ext_clip_paste, NULL},
|
||||
{"paste_from_history", mc_editor_cmd_paste_from_history, NULL},
|
||||
|
||||
{"format_paragraph", mc_editor_cmd_format_paragraph, (void *) FALSE},
|
||||
{"format_paragraph_force", mc_editor_cmd_format_paragraph, (void *) TRUE},
|
||||
{"format_paragraph_auto", mc_editor_cmd_format_paragraph_auto, NULL},
|
||||
|
||||
{"save_as", mc_editor_cmd_save_as, NULL},
|
||||
{"save_confirm", mc_editor_cmd_save_confirm, NULL},
|
||||
{"save_block", mc_editor_cmd_save_block, NULL},
|
||||
|
||||
{"insert_file", mc_editor_cmd_insert_file, NULL},
|
||||
{"file_load_prev", mc_editor_cmd_file_load_prev, NULL},
|
||||
{"file_load_next", mc_editor_cmd_file_load_next, NULL},
|
||||
{"syntax_show_dialog", mc_editor_cmd_syntax_show_dialog, NULL},
|
||||
|
||||
{"search", mc_editor_cmd_search, (void *) FALSE},
|
||||
{"search_continue", mc_editor_cmd_search, (void *) TRUE},
|
||||
{"replace", mc_editor_cmd_replace, (void *) FALSE},
|
||||
{"replace_continue", mc_editor_cmd_replace, (void *) TRUE},
|
||||
|
||||
{"complete", mc_editor_cmd_complete, (void *) FALSE},
|
||||
{"match_keyword", mc_editor_cmd_match_keyword, (void *) FALSE},
|
||||
{"print_current_date", mc_editor_cmd_print_current_date, (void *) FALSE},
|
||||
{"goto_line", mc_editor_cmd_goto_line, (void *) FALSE},
|
||||
{"goto_matching_bracket", mc_editor_cmd_goto_matching_bracket, (void *) FALSE},
|
||||
{"user_menu", mc_editor_cmd_user_menu, (void *) FALSE},
|
||||
{"sort", mc_editor_cmd_sort, (void *) FALSE},
|
||||
{"run_external_command", mc_editor_cmd_run_external_command, (void *) FALSE},
|
||||
{"mail", mc_editor_cmd_mail, (void *) FALSE},
|
||||
{"insert_literal", mc_editor_cmd_insert_literal, (void *) FALSE},
|
||||
|
||||
{"macro_record_start_stop", mc_editor_cmd_macro_record_start_stop, (void *) FALSE},
|
||||
{"macro_repeat_start_stop", mc_editor_cmd_macro_repeat_start_stop, (void *) FALSE},
|
||||
{"macro_store", mc_editor_cmd_macro_store, (void *) FALSE},
|
||||
{"macro_delete", mc_editor_cmd_macro_delete, (void *) FALSE},
|
||||
{"macro_repeat", mc_editor_cmd_macro_repeat, (void *) FALSE},
|
||||
|
||||
#ifdef HAVE_ASPELL
|
||||
{"spell_set_language", mc_editor_cmd_spell_set_language, (void *) FALSE},
|
||||
{"spell_check", mc_editor_cmd_spell_check, (void *) FALSE},
|
||||
{"spell_suggest_word", mc_editor_cmd_spell_suggest_word, (void *) FALSE},
|
||||
#endif /* HAVE_ASPELL */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
{"select_codepage", mc_editor_cmd_select_codepage, (void *) FALSE},
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
event_init_t standard_events[] =
|
||||
{
|
||||
{MCEVENT_GROUP_EDITOR, core_group_events},
|
||||
{NULL, NULL}
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
mc_event_mass_add (standard_events, error);
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
161
src/editor/event.h
Normal file
161
src/editor/event.h
Normal file
@ -0,0 +1,161 @@
|
||||
#ifndef MC__EDIT_EVENT_H
|
||||
#define MC__EDIT_EVENT_H
|
||||
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "editwidget.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NONE,
|
||||
TO_LEFT,
|
||||
TO_RIGHT,
|
||||
TO_WORD_BEGIN,
|
||||
TO_WORD_END,
|
||||
TO_UP,
|
||||
TO_DOWN,
|
||||
TO_PARAGRAPH_UP,
|
||||
TO_PARAGRAPH_DOWN,
|
||||
TO_SCROLL_UP,
|
||||
TO_SCROLL_DOWN,
|
||||
TO_PAGE_UP,
|
||||
TO_PAGE_DOWN,
|
||||
TO_PAGE_BEGIN,
|
||||
TO_PAGE_END,
|
||||
TO_LINE_BEGIN,
|
||||
TO_LINE_END,
|
||||
TO_FILE_BEGIN,
|
||||
TO_FILE_END,
|
||||
} mc_editor_event_direction_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct WEdit *editor;
|
||||
int char_for_insertion;
|
||||
long line;
|
||||
} mc_editor_event_data_insert_char_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct WEdit *editor;
|
||||
gboolean is_mark;
|
||||
gboolean is_column;
|
||||
mc_editor_event_direction_t direction;
|
||||
long line;
|
||||
} mc_editor_event_data_move_cursor_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct WEdit *editor;
|
||||
gboolean return_value;
|
||||
} mc_editor_event_data_ret_boolean_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WEdit *editor;
|
||||
const char *menu_file;
|
||||
int selected_entry;
|
||||
} mc_editor_event_data_user_menu_t;
|
||||
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void mc_editor_init_events (GError ** error);
|
||||
|
||||
gboolean mc_editor_cmd_backspace (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_delete (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_delete_word (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_delete_line (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_enter (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_insert_char_raw (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_insert_char (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_undo (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_redo (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_toggle_fullscreen (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_move_cursor (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_tab (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_switch_insert_overwrite (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_mark (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_mark_column (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_mark_all (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_unmark (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_mark_word (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_mark_line (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_bookmark_toggle (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_bookmark_flush (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_bookmark_next (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_bookmark_prev (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_block_copy (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_block_delete (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_block_move (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_block_move_to_left (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_block_move_to_right (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_ext_clip_copy (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_ext_clip_cut (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_ext_clip_paste (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_paste_from_history (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_format_paragraph (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_format_paragraph_auto (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_save_as (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_save_confirm (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_save_block (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_insert_file (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_file_load_prev (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_file_load_next (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_syntax_show_dialog (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_search (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_replace (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_complete (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_match_keyword (event_info_t * event_info, gpointer data, GError ** error);
|
||||
|
||||
gboolean mc_editor_cmd_print_current_date (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_goto_line (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_macro_delete (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_goto_matching_bracket (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_user_menu (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_sort (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_run_external_command (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_mail (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_insert_literal (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_macro_record_start_stop (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_macro_repeat_start_stop (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_macro_store (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_macro_repeat (event_info_t * event_info, gpointer data, GError ** error);
|
||||
|
||||
#ifdef HAVE_ASPELL
|
||||
gboolean mc_editor_cmd_spell_set_language (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
gboolean mc_editor_cmd_spell_check (event_info_t * event_info, gpointer data, GError ** error);
|
||||
gboolean mc_editor_cmd_spell_suggest_word (event_info_t * event_info, gpointer data,
|
||||
GError ** error);
|
||||
#endif /* HAVE_ASPELL */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
gboolean mc_editor_cmd_select_codepage (event_info_t * event_info, gpointer data, GError ** error);
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__EDIT_EVENT_H */
|
@ -53,6 +53,7 @@
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "editwidget.h"
|
||||
#include "event.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -468,11 +469,9 @@ test_indent (const WEdit * edit, off_t p, off_t q)
|
||||
return indent;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
static void
|
||||
format_paragraph (WEdit * edit, gboolean force)
|
||||
{
|
||||
off_t p, q;
|
||||
@ -488,6 +487,7 @@ format_paragraph (WEdit * edit, gboolean force)
|
||||
if (edit_line_is_blank (edit, edit->buffer.curs_line))
|
||||
return;
|
||||
|
||||
edit->force |= REDRAW_PAGE;
|
||||
p = begin_paragraph (edit, force, &lines);
|
||||
q = end_paragraph (edit, force);
|
||||
indent = test_indent (edit, p, q);
|
||||
@ -543,11 +543,18 @@ format_paragraph (WEdit * edit, gboolean force)
|
||||
/* try move to the start of next paragraph */
|
||||
if (edit->buffer.curs_line < edit->buffer.lines)
|
||||
{
|
||||
edit_execute_cmd (edit, CK_Home, -1);
|
||||
mc_editor_event_data_move_cursor_t cursor_event_data = {
|
||||
.editor = edit,
|
||||
.is_mark = FALSE,
|
||||
.is_column = FALSE,
|
||||
.direction = TO_LINE_BEGIN
|
||||
};
|
||||
|
||||
mc_event_raise (MCEVENT_GROUP_EDITOR, "move_cursor", &cursor_event_data, NULL);
|
||||
cursor_event_data.direction = TO_DOWN;
|
||||
do
|
||||
{
|
||||
edit_execute_cmd (edit, CK_Down, -1);
|
||||
mc_event_raise (MCEVENT_GROUP_EDITOR, "move_cursor", &cursor_event_data, NULL);
|
||||
}
|
||||
while (edit->buffer.curs_line < edit->buffer.lines
|
||||
&& edit_line_is_blank (edit, edit->buffer.curs_line));
|
||||
@ -555,3 +562,38 @@ format_paragraph (WEdit * edit, gboolean force)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_format_paragraph (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
gboolean force = (gboolean) (intptr_t) event_info->init_data;
|
||||
|
||||
(void) error;
|
||||
|
||||
format_paragraph (edit, force);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_format_paragraph_auto (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) error;
|
||||
(void) event_info;
|
||||
|
||||
if (option_auto_para_formatting)
|
||||
format_paragraph (edit, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "editwidget.h"
|
||||
#include "editcmd_dialogs.h"
|
||||
|
||||
#include "event.h"
|
||||
#include "macro.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -140,15 +141,24 @@ edit_delete_macro (WEdit * edit, int hotkey)
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
edit_delete_macro_cmd (WEdit * edit)
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_macro_delete (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
int hotkey;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
hotkey = editcmd_dialog_raw_key_query (_("Delete macro"), _("Press macro hotkey:"), TRUE);
|
||||
|
||||
if (hotkey != 0 && !edit_delete_macro (edit, hotkey))
|
||||
message (D_ERROR, _("Delete macro"), _("Macro not deleted"));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -186,11 +196,13 @@ edit_execute_macro (WEdit * edit, int hotkey)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
/** returns FALSE on error */
|
||||
gboolean
|
||||
edit_store_macro_cmd (WEdit * edit)
|
||||
mc_editor_cmd_macro_store (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
int i;
|
||||
int hotkey;
|
||||
GString *marcros_string;
|
||||
@ -202,17 +214,20 @@ edit_store_macro_cmd (WEdit * edit)
|
||||
gboolean have_macro = FALSE;
|
||||
char *skeyname = NULL;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
hotkey =
|
||||
editcmd_dialog_raw_key_query (_("Save macro"), _("Press the macro's new hotkey:"), TRUE);
|
||||
if (hotkey == ESC_CHAR)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
tmp_act = keybind_lookup_keymap_command (editor_map, hotkey);
|
||||
|
||||
/* return FALSE if try assign macro into restricted hotkeys */
|
||||
if (tmp_act == CK_MacroStartRecord
|
||||
|| tmp_act == CK_MacroStopRecord || tmp_act == CK_MacroStartStopRecord)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
edit_delete_macro (edit, hotkey);
|
||||
|
||||
@ -221,7 +236,7 @@ edit_store_macro_cmd (WEdit * edit)
|
||||
g_free (macros_fname);
|
||||
|
||||
if (macros_config == NULL)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
|
||||
|
||||
@ -264,33 +279,40 @@ edit_store_macro_cmd (WEdit * edit)
|
||||
g_string_free (marcros_string, TRUE);
|
||||
mc_config_save_file (macros_config, NULL);
|
||||
mc_config_deinit (macros_config);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
edit_repeat_macro_cmd (WEdit * edit)
|
||||
mc_editor_cmd_macro_repeat (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
int i, j;
|
||||
char *f;
|
||||
long count_repeat;
|
||||
char *error = NULL;
|
||||
char *error_str = NULL;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
f = input_dialog (_("Repeat last commands"), _("Repeat times:"), MC_HISTORY_EDIT_REPEAT, NULL,
|
||||
INPUT_COMPLETE_NONE);
|
||||
if (f == NULL || *f == '\0')
|
||||
{
|
||||
g_free (f);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
count_repeat = strtol (f, &error, 0);
|
||||
count_repeat = strtol (f, &error_str, 0);
|
||||
|
||||
if (*error != '\0')
|
||||
if (*error_str != '\0')
|
||||
{
|
||||
g_free (f);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_free (f);
|
||||
@ -302,6 +324,7 @@ edit_repeat_macro_cmd (WEdit * edit)
|
||||
for (i = 0; i < macro_index; i++)
|
||||
edit_execute_cmd (edit, record_macro_buf[i].action, record_macro_buf[i].ch);
|
||||
edit_update_screen (edit);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -388,35 +411,52 @@ edit_load_macro_cmd (WEdit * edit)
|
||||
g_strfreev (keys);
|
||||
mc_config_deinit (macros_config);
|
||||
edit_macro_sort_by_hotkey ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* }}} Macro stuff end here */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
void
|
||||
edit_begin_end_macro_cmd (WEdit * edit)
|
||||
gboolean
|
||||
mc_editor_cmd_macro_record_start_stop (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
/* edit is a pointer to the widget */
|
||||
if (edit != NULL)
|
||||
{
|
||||
unsigned long command = macro_index < 0 ? CK_MacroStartRecord : CK_MacroStopRecord;
|
||||
edit_execute_key_command (edit, command, -1);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
void
|
||||
edit_begin_end_repeat_cmd (WEdit * edit)
|
||||
gboolean
|
||||
mc_editor_cmd_macro_repeat_start_stop (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
/* edit is a pointer to the widget */
|
||||
if (edit != NULL)
|
||||
{
|
||||
unsigned long command = macro_index < 0 ? CK_RepeatStartRecord : CK_RepeatStopRecord;
|
||||
edit_execute_key_command (edit, command, -1);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -11,14 +11,9 @@
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int edit_store_macro_cmd (WEdit * edit);
|
||||
gboolean edit_load_macro_cmd (WEdit * edit);
|
||||
void edit_delete_macro_cmd (WEdit * edit);
|
||||
gboolean edit_repeat_macro_cmd (WEdit * edit);
|
||||
|
||||
gboolean edit_execute_macro (WEdit * edit, int hotkey);
|
||||
void edit_begin_end_macro_cmd (WEdit * edit);
|
||||
void edit_begin_end_repeat_cmd (WEdit * edit);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC__EDIT_MACRO_H */
|
||||
|
218
src/editor/spell_cmd.c
Normal file
218
src/editor/spell_cmd.c
Normal file
@ -0,0 +1,218 @@
|
||||
/*
|
||||
Editor spell checker dialogs
|
||||
|
||||
Copyright (C) 2012-2014
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2012
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h" /* str_term_width1 */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "editwidget.h"
|
||||
|
||||
#include "event.h"
|
||||
#include "spell.h"
|
||||
#include "spell_dialogs.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
edit_suggest_current_word (WEdit * edit)
|
||||
{
|
||||
gsize cut_len = 0;
|
||||
gsize word_len = 0;
|
||||
off_t word_start = 0;
|
||||
int retval = B_SKIP_WORD;
|
||||
GString *match_word;
|
||||
|
||||
/* search start of word to spell check */
|
||||
match_word = edit_buffer_get_word_from_pos (&edit->buffer, edit->buffer.curs1, &word_start,
|
||||
&cut_len);
|
||||
word_len = match_word->len;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (mc_global.source_codepage >= 0 && (mc_global.source_codepage != mc_global.display_codepage))
|
||||
{
|
||||
GString *tmp_word;
|
||||
|
||||
tmp_word = str_convert_to_display (match_word->str);
|
||||
g_string_free (match_word, TRUE);
|
||||
match_word = tmp_word;
|
||||
}
|
||||
#endif
|
||||
if (!aspell_check (match_word->str, (int) word_len))
|
||||
{
|
||||
GArray *suggest;
|
||||
unsigned int res;
|
||||
|
||||
suggest = g_array_new (TRUE, FALSE, sizeof (char *));
|
||||
|
||||
res = aspell_suggest (suggest, match_word->str, (int) word_len);
|
||||
if (res != 0)
|
||||
{
|
||||
char *new_word = NULL;
|
||||
|
||||
edit->found_start = word_start;
|
||||
edit->found_len = word_len;
|
||||
edit->force |= REDRAW_PAGE;
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
edit_render_keypress (edit);
|
||||
|
||||
retval = spell_dialog_spell_suggest_show (edit, match_word->str, &new_word, suggest);
|
||||
edit_cursor_move (edit, word_len - cut_len);
|
||||
|
||||
if (retval == B_ENTER && new_word != NULL)
|
||||
{
|
||||
guint i;
|
||||
char *cp_word;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (mc_global.source_codepage >= 0 &&
|
||||
(mc_global.source_codepage != mc_global.display_codepage))
|
||||
{
|
||||
GString *tmp_word;
|
||||
|
||||
tmp_word = str_convert_to_input (new_word);
|
||||
g_free (new_word);
|
||||
new_word = g_string_free (tmp_word, FALSE);
|
||||
}
|
||||
#endif
|
||||
cp_word = new_word;
|
||||
for (i = 0; i < word_len; i++)
|
||||
edit_backspace (edit, TRUE);
|
||||
for (; *new_word; new_word++)
|
||||
edit_insert (edit, *new_word);
|
||||
g_free (cp_word);
|
||||
}
|
||||
else if (retval == B_ADD_WORD && match_word != NULL)
|
||||
aspell_add_to_dict (match_word->str, (int) word_len);
|
||||
}
|
||||
|
||||
g_array_free (suggest, TRUE);
|
||||
edit->found_start = 0;
|
||||
edit->found_len = 0;
|
||||
}
|
||||
g_string_free (match_word, TRUE);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_spell_suggest_word (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
edit_suggest_current_word (edit);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_spell_check (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
WEdit *edit = (WEdit *) data;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
|
||||
if (edit->buffer.curs_line > 0)
|
||||
{
|
||||
edit_cursor_move (edit, -edit->buffer.curs1);
|
||||
edit_move_to_prev_col (edit, 0);
|
||||
edit_update_curs_row (edit);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
c2 = edit_buffer_get_current_byte (&edit->buffer);
|
||||
|
||||
do
|
||||
{
|
||||
if (edit->buffer.curs1 >= edit->buffer.size)
|
||||
return TRUE;
|
||||
|
||||
c1 = c2;
|
||||
edit_cursor_move (edit, 1);
|
||||
c2 = edit_buffer_get_current_byte (&edit->buffer);
|
||||
}
|
||||
while (is_break_char (c1) || is_break_char (c2));
|
||||
}
|
||||
while (edit_suggest_current_word (edit) != B_CANCEL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* event callback */
|
||||
|
||||
gboolean
|
||||
mc_editor_cmd_spell_set_language (event_info_t * event_info, gpointer data, GError ** error)
|
||||
{
|
||||
GArray *lang_list;
|
||||
|
||||
(void) event_info;
|
||||
(void) error;
|
||||
(void) data;
|
||||
|
||||
|
||||
lang_list = g_array_new (TRUE, FALSE, sizeof (char *));
|
||||
if (aspell_get_lang_list (lang_list) != 0)
|
||||
{
|
||||
char *lang;
|
||||
|
||||
lang = spell_dialog_lang_list_show (lang_list);
|
||||
if (lang != NULL)
|
||||
(void) aspell_set_lang (lang);
|
||||
}
|
||||
aspell_array_clean (lang_list);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
@ -1744,7 +1744,7 @@ do_nc (GError ** error)
|
||||
gboolean ret;
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
edit_stack_init ();
|
||||
mc_editor_init (error);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DIFF_VIEW
|
||||
@ -1790,7 +1790,7 @@ do_nc (GError ** error)
|
||||
current_panel = NULL;
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
edit_stack_free ();
|
||||
mc_editor_deinit (error);
|
||||
#endif
|
||||
|
||||
if ((quit & SUBSHELL_EXIT) == 0)
|
||||
|
@ -69,17 +69,6 @@ edit_get_syntax_color (WEdit * _edit, off_t _byte_index)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @Mock */
|
||||
gboolean
|
||||
edit_load_macro_cmd (WEdit * _edit)
|
||||
{
|
||||
(void) _edit;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @CapturedValue */
|
||||
static const WEdit *editcmd_dialog_completion_show__edit;
|
||||
/* @CapturedValue */
|
||||
|
Loading…
Reference in New Issue
Block a user