2009-02-07 00:09:50 +03:00
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \brief Header: editor widget WEdit
|
|
|
|
*/
|
|
|
|
|
2004-12-03 20:09:27 +03:00
|
|
|
#ifndef MC_EDIT_WIDGET_H
|
|
|
|
#define MC_EDIT_WIDGET_H
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2003-10-29 11:54:22 +03:00
|
|
|
#include "../src/dialog.h" /* Widget */
|
2009-04-25 11:25:13 +04:00
|
|
|
#include "../src/search/search.h" /* mc_search_t */
|
2009-06-14 19:18:27 +04:00
|
|
|
|
|
|
|
#include "edit-impl.h"
|
2009-07-05 19:04:42 +04:00
|
|
|
#include "../src/keybind.h"
|
|
|
|
|
2002-11-30 21:07:42 +03:00
|
|
|
#define MAX_MACRO_LENGTH 1024
|
2002-12-06 07:49:58 +03:00
|
|
|
#define N_LINE_CACHES 32
|
2002-11-30 21:07:42 +03:00
|
|
|
|
|
|
|
struct _book_mark {
|
2002-12-06 07:49:58 +03:00
|
|
|
int line; /* line number */
|
|
|
|
int c; /* color */
|
2002-11-30 21:07:42 +03:00
|
|
|
struct _book_mark *next;
|
|
|
|
struct _book_mark *prev;
|
|
|
|
};
|
|
|
|
|
2001-08-24 22:23:17 +04:00
|
|
|
struct syntax_rule {
|
|
|
|
unsigned short keyword;
|
|
|
|
unsigned char end;
|
|
|
|
unsigned char context;
|
|
|
|
unsigned char _context;
|
|
|
|
unsigned char border;
|
|
|
|
};
|
|
|
|
|
2002-11-29 06:01:06 +03:00
|
|
|
struct WEdit {
|
2001-08-24 22:23:17 +04:00
|
|
|
Widget widget;
|
2002-12-06 07:49:58 +03:00
|
|
|
|
2001-08-24 22:23:17 +04:00
|
|
|
int num_widget_lines;
|
|
|
|
int num_widget_columns;
|
|
|
|
|
|
|
|
char *filename; /* Name of the file */
|
2003-07-31 20:38:07 +04:00
|
|
|
char *dir; /* NULL if filename is absolute */
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2002-12-06 07:49:58 +03:00
|
|
|
/* dynamic buffers and cursor position for editor: */
|
|
|
|
long curs1; /* position of the cursor from the beginning of the file. */
|
|
|
|
long curs2; /* position from the end of the file */
|
2005-05-11 03:04:32 +04:00
|
|
|
unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
|
|
|
|
unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2009-04-13 19:19:06 +04:00
|
|
|
/* UTF8 */
|
2009-04-17 01:14:48 +04:00
|
|
|
char charbuf[4 + 1];
|
2009-04-13 19:19:06 +04:00
|
|
|
int charpoint;
|
2002-12-06 07:49:58 +03:00
|
|
|
/* search variables */
|
2009-04-23 15:30:14 +04:00
|
|
|
mc_search_t *search;
|
|
|
|
|
2009-04-29 17:13:12 +04:00
|
|
|
unsigned int search_type;
|
|
|
|
int replace_mode;
|
|
|
|
int replace_backwards;
|
|
|
|
int replace_case;
|
2009-08-19 23:36:23 +04:00
|
|
|
int only_in_selection;
|
2009-08-22 15:06:01 +04:00
|
|
|
int whole_words;
|
2009-04-30 17:58:28 +04:00
|
|
|
int all_codepages;
|
2009-04-29 17:13:12 +04:00
|
|
|
|
2001-08-24 22:23:17 +04:00
|
|
|
long search_start; /* First character to start searching from */
|
|
|
|
int found_len; /* Length of found string or 0 if none was found */
|
|
|
|
long found_start; /* the found word from a search - start position */
|
|
|
|
|
2002-12-06 07:49:58 +03:00
|
|
|
/* display information */
|
2001-08-24 22:23:17 +04:00
|
|
|
long last_byte; /* Last byte of file */
|
|
|
|
long start_display; /* First char displayed */
|
|
|
|
long start_col; /* First displayed column, negative */
|
|
|
|
long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
|
2002-12-06 07:49:58 +03:00
|
|
|
long curs_row; /* row position of cursor on the screen */
|
|
|
|
long curs_col; /* column position on screen */
|
2009-08-15 02:51:39 +04:00
|
|
|
long over_col; /* pos after '\n' */
|
2001-08-24 22:23:17 +04:00
|
|
|
int force; /* how much of the screen do we redraw? */
|
2005-08-16 00:34:26 +04:00
|
|
|
unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
|
|
|
|
unsigned int modified:1; /* File has been modified and needs saving */
|
|
|
|
unsigned int loading_done:1;/* File has been loaded into the editor */
|
|
|
|
unsigned int locked:1; /* We hold lock on current file */
|
|
|
|
unsigned int screen_modified:1; /* File has been changed since the last screen draw */
|
|
|
|
unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
|
|
|
|
unsigned int highlight:1; /* There is a selected block */
|
2009-04-09 18:23:08 +04:00
|
|
|
unsigned int utf8:1; /* It's multibyte file codeset */
|
2002-12-06 07:49:58 +03:00
|
|
|
long prev_col; /* recent column position of the cursor - used when moving
|
2001-08-24 22:23:17 +04:00
|
|
|
up or down past lines that are shorter than the current line */
|
2002-12-06 07:49:58 +03:00
|
|
|
long curs_line; /* line number of the cursor. */
|
|
|
|
long start_line; /* line number of the top of the page */
|
|
|
|
|
|
|
|
/* file info */
|
|
|
|
long total_lines; /* total lines in the file */
|
|
|
|
long mark1; /* position of highlight start */
|
|
|
|
long mark2; /* position of highlight end */
|
|
|
|
int column1; /* position of column highlight start */
|
|
|
|
int column2; /* position of column highlight end */
|
|
|
|
long bracket; /* position of a matching bracket */
|
|
|
|
|
|
|
|
/* cache speedup for line lookups */
|
2001-08-24 22:23:17 +04:00
|
|
|
int caches_valid;
|
|
|
|
int line_numbers[N_LINE_CACHES];
|
|
|
|
long line_offsets[N_LINE_CACHES];
|
|
|
|
|
|
|
|
struct _book_mark *book_mark;
|
|
|
|
|
2002-12-06 07:49:58 +03:00
|
|
|
/* undo stack and pointers */
|
2001-08-24 22:23:17 +04:00
|
|
|
unsigned long stack_pointer;
|
|
|
|
long *undo_stack;
|
|
|
|
unsigned long stack_size;
|
|
|
|
unsigned long stack_size_mask;
|
|
|
|
unsigned long stack_bottom;
|
2005-08-16 00:34:26 +04:00
|
|
|
unsigned int stack_disable:1; /* If not 0, don't save events in the undo stack */
|
2002-12-16 08:21:42 +03:00
|
|
|
|
|
|
|
struct stat stat1; /* Result of mc_fstat() on the file */
|
2007-02-03 04:03:53 +03:00
|
|
|
unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2002-12-06 07:49:58 +03:00
|
|
|
/* syntax higlighting */
|
2001-08-24 22:23:17 +04:00
|
|
|
struct _syntax_marker *syntax_marker;
|
|
|
|
struct context_rule **rules;
|
|
|
|
long last_get_rule;
|
|
|
|
struct syntax_rule rule;
|
|
|
|
char *syntax_type; /* description of syntax highlighting type being used */
|
2003-10-24 03:23:46 +04:00
|
|
|
GTree *defines; /* List of defines */
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2002-12-06 07:49:58 +03:00
|
|
|
/* macro stuff */
|
|
|
|
int macro_i; /* index to macro[], -1 if not recording a macro */
|
2002-10-21 06:06:03 +04:00
|
|
|
int macro_depth; /* depth of the macro recursion */
|
2001-08-24 22:23:17 +04:00
|
|
|
struct macro macro[MAX_MACRO_LENGTH];
|
2005-07-20 15:56:30 +04:00
|
|
|
|
|
|
|
/* user map stuff */
|
2009-08-13 09:59:31 +04:00
|
|
|
GIConv converter;
|
2005-07-20 15:56:30 +04:00
|
|
|
|
2009-08-29 16:22:39 +04:00
|
|
|
/* line break */
|
|
|
|
LineBreaks lb;
|
2005-07-20 15:56:30 +04:00
|
|
|
int extmod;
|
|
|
|
|
|
|
|
char *labels[10];
|
2009-04-23 15:30:14 +04:00
|
|
|
|
2002-11-29 06:01:06 +03:00
|
|
|
};
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2009-06-14 19:18:27 +04:00
|
|
|
#endif /* MC_EDIT_WIDGET_H */
|