root/src/editor/editwidget.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /** \file
   2  *  \brief Header: editor widget WEdit
   3  */
   4 
   5 #ifndef MC__EDIT_WIDGET_H
   6 #define MC__EDIT_WIDGET_H
   7 
   8 #include <limits.h>             /* MB_LEN_MAX */
   9 
  10 #include "lib/search.h"         /* mc_search_t */
  11 #include "lib/widget.h"         /* Widget */
  12 
  13 #include "edit-impl.h"
  14 #include "editbuffer.h"
  15 
  16 /*** typedefs(not structures) and defined constants **********************************************/
  17 
  18 #define N_LINE_CACHES 32
  19 
  20 /*** enums ***************************************************************************************/
  21 
  22 /**
  23     enum for store the search conditions check results.
  24     (if search condition have BOL(^) or EOL ($) regexp checial characters).
  25 */
  26 typedef enum
  27 {
  28     AT_START_LINE = (1 << 0),
  29     AT_END_LINE = (1 << 1)
  30 } edit_search_line_t;
  31 
  32 /*** structures declarations (and typedefs of structures)*****************************************/
  33 
  34 typedef struct edit_book_mark_t edit_book_mark_t;
  35 struct edit_book_mark_t
  36 {
  37     long line;                  /* line number */
  38     int c;                      /* color */
  39     edit_book_mark_t *next;
  40     edit_book_mark_t *prev;
  41 };
  42 
  43 typedef struct edit_syntax_rule_t edit_syntax_rule_t;
  44 struct edit_syntax_rule_t
  45 {
  46     unsigned short keyword;
  47     off_t end;
  48     unsigned char context;
  49     unsigned char _context;
  50     unsigned char border;
  51 };
  52 
  53 /*
  54  * State of WEdit window
  55  * MCEDIT_DRAG_NONE   - window is in normal mode
  56  * MCEDIT_DRAG_MOVE   - window is being moved
  57  * MCEDIT_DRAG_RESIZE - window is being resized
  58  */
  59 typedef enum
  60 {
  61     MCEDIT_DRAG_NONE = 0,
  62     MCEDIT_DRAG_MOVE,
  63     MCEDIT_DRAG_RESIZE
  64 } mcedit_drag_state_t;
  65 
  66 struct WEdit
  67 {
  68     Widget widget;
  69     mcedit_drag_state_t drag_state;
  70     int drag_state_start;       /* save cursor position before window moving */
  71 
  72     /* save location before move/resize or toggle to fullscreen */
  73     WRect loc_prev;
  74 
  75     vfs_path_t *filename_vpath; /* Name of the file */
  76     vfs_path_t *dir_vpath;      /* NULL if filename is absolute */
  77 
  78     /* dynamic buffers and cursor position for editor: */
  79     edit_buffer_t buffer;
  80 
  81 #ifdef HAVE_CHARSET
  82     /* multibyte support */
  83     gboolean utf8;              /* It's multibyte file codeset */
  84     GIConv converter;
  85     char charbuf[MB_LEN_MAX + 1];
  86     int charpoint;
  87 #endif
  88 
  89     /* search handler */
  90     mc_search_t *search;
  91     int replace_mode;
  92     /* is search conditions should be started from BOL(^) or ended with EOL($) */
  93     edit_search_line_t search_line_type;
  94 
  95     char *last_search_string;   /* String that have been searched */
  96     off_t search_start;         /* First character to start searching from */
  97     unsigned long found_len;    /* Length of found string or 0 if none was found */
  98     off_t found_start;          /* the found word from a search - start position */
  99 
 100     /* display information */
 101     long start_display;         /* First char displayed */
 102     long start_col;             /* First displayed column, negative */
 103     long max_column;            /* The maximum cursor position ever reached used to calc hori scroll bar */
 104     long curs_row;              /* row position of cursor on the screen */
 105     long curs_col;              /* column position on screen */
 106     long over_col;              /* pos after '\n' */
 107     int force;                  /* how much of the screen do we redraw? */
 108     unsigned int overwrite:1;   /* Overwrite on type mode (as opposed to insert) */
 109     unsigned int modified:1;    /* File has been modified and needs saving */
 110     unsigned int loading_done:1;        /* File has been loaded into the editor */
 111     unsigned int locked:1;      /* We hold lock on current file */
 112     unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
 113     unsigned int highlight:1;   /* There is a selected block */
 114     unsigned int column_highlight:1;
 115     unsigned int fullscreen:1;  /* Is window fullscreen or not */
 116     long prev_col;              /* recent column position of the cursor - used when moving
 117                                    up or down past lines that are shorter than the current line */
 118     long start_line;            /* line number of the top of the page */
 119 
 120     /* file info */
 121     off_t mark1;                /* position of highlight start */
 122     off_t mark2;                /* position of highlight end */
 123     off_t end_mark_curs;        /* position of cursor after end of highlighting */
 124     long column1;               /* position of column highlight start */
 125     long column2;               /* position of column highlight end */
 126     off_t bracket;              /* position of a matching bracket */
 127     off_t last_bracket;         /* previous position of a matching bracket */
 128 
 129     /* cache speedup for line lookups */
 130     gboolean caches_valid;
 131     long line_numbers[N_LINE_CACHES];
 132     off_t line_offsets[N_LINE_CACHES];
 133 
 134     edit_book_mark_t *book_mark;
 135     GArray *serialized_bookmarks;
 136 
 137     /* undo stack and pointers */
 138     unsigned long undo_stack_pointer;
 139     long *undo_stack;
 140     unsigned long undo_stack_size;
 141     unsigned long undo_stack_size_mask;
 142     unsigned long undo_stack_bottom;
 143     unsigned int undo_stack_disable:1;  /* If not 0, don't save events in the undo stack */
 144 
 145     unsigned long redo_stack_pointer;
 146     long *redo_stack;
 147     unsigned long redo_stack_size;
 148     unsigned long redo_stack_size_mask;
 149     unsigned long redo_stack_bottom;
 150     unsigned int redo_stack_reset:1;    /* If 1, need clear redo stack */
 151 
 152     struct stat stat1;          /* Result of mc_fstat() on the file */
 153     unsigned long attrs;        /* Result of mc_fgetflags() on the file */
 154     gboolean attrs_ok;          /* mc_fgetflags() == 0 */
 155 
 156     unsigned int skip_detach_prompt:1;  /* Do not prompt whether to detach a file anymore */
 157 
 158     /* syntax highlighting */
 159     GSList *syntax_marker;
 160     GPtrArray *rules;
 161     off_t last_get_rule;
 162     edit_syntax_rule_t rule;
 163     char *syntax_type;          /* description of syntax highlighting type being used */
 164     GTree *defines;             /* List of defines */
 165     gboolean is_case_insensitive;       /* selects language case sensitivity */
 166 
 167     /* line break */
 168     LineBreaks lb;
 169 };
 170 
 171 /*** global variables defined in .c file *********************************************************/
 172 
 173 /*** declarations of public functions ************************************************************/
 174 
 175 /*** inline functions ****************************************************************************/
 176 #endif /* MC__EDIT_WIDGET_H */

/* [previous][next][first][last][top][bottom][index][help]  */