1 /* Global declarations for the ed editor. */
2 /* GNU ed - The GNU line editor.
3 Copyright (C) 1993, 1994 Andrew Moore, Talke Studio
4 Copyright (C) 2006-2015 Antonio Diaz Diaz.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 enum Bool { false = 0, true = 1 };
22 typedef enum Bool bool;
27 GLB = 0x01, /* global command */
28 GLS = 0x02, /* list after command */
29 GNP = 0x04, /* enumerate after command */
30 GPR = 0x08, /* print after command */
31 GSG = 0x10 /* global substitute */
35 typedef struct line /* Line node */
39 long pos; /* position of text in scratch buffer */
40 int len; /* length of line ('\n' is not stored) */
47 enum { UADD = 0, UDEL = 1, UMOV = 2, VMOV = 3 } type;
48 line_t * head; /* head of list */
49 line_t * tail; /* tail of list */
54 #define max( a,b ) ( (( a ) > ( b )) ? ( a ) : ( b ) )
57 #define min( a,b ) ( (( a ) < ( b )) ? ( a ) : ( b ) )
61 /* defined in buffer.c */
62 bool append_lines( const char ** const ibufpp, const int addr,
63 const bool isglobal );
64 bool close_sbuf( void );
65 bool copy_lines( const int first_addr, const int second_addr, const int addr );
66 int current_addr( void );
67 int dec_addr( int addr );
68 bool delete_lines( const int from, const int to, const bool isglobal );
69 int get_line_node_addr( const line_t * const lp );
70 char * get_sbuf_line( const line_t * const lp );
71 int inc_addr( int addr );
72 int inc_current_addr( void );
73 bool init_buffers( void );
74 bool isbinary( void );
75 bool join_lines( const int from, const int to, const bool isglobal );
76 int last_addr( void );
77 bool modified( void );
78 bool move_lines( const int first_addr, const int second_addr, const int addr,
79 const bool isglobal );
80 bool newline_added( void );
81 bool open_sbuf( void );
82 int path_max( const char * filename );
83 bool put_lines( const int addr );
84 const char * put_sbuf_line( const char * const buf, const int size,
86 line_t * search_line_node( const int addr );
87 void set_binary( void );
88 void set_current_addr( const int addr );
89 void set_modified( const bool m );
90 void set_newline_added( void );
91 bool yank_lines( const int from, const int to );
92 void clear_undo_stack( void );
93 undo_t * push_undo_atom( const int type, const int from, const int to );
94 void reset_undo_state( void );
95 bool undo( const bool isglobal );
97 /* defined in global.c */
98 void clear_active_list( void );
99 const line_t * next_active_node( void );
100 bool set_active_node( const line_t * const lp );
101 void unset_active_nodes( const line_t * bp, const line_t * const ep );
103 /* defined in io.c */
104 bool display_lines( int from, const int to, const int gflags );
105 bool get_extended_line( const char ** const ibufpp, int * const lenp,
106 const bool strip_escaped_newlines );
107 const char * get_tty_line( int * const sizep );
108 int read_file( const char * const filename, const int addr );
109 int write_file( const char * const filename, const char * const mode,
110 const int from, const int to );
112 /* defined in main.c */
113 bool is_regular_file( const int fd );
114 bool may_access_filename( const char * const name );
115 bool restricted( void );
116 bool scripted( void );
117 void show_strerror( const char * const filename, const int errcode );
118 bool traditional( void );
120 /* defined in main_loop.c */
121 int main_loop( const bool loose );
122 void set_def_filename( const char * const s );
123 void set_error_msg( const char * msg );
124 void set_prompt( const char * const s );
125 void set_verbose( void );
126 void unmark_line_node( const line_t * const lp );
128 /* defined in regex.c */
129 bool build_active_list( const char ** const ibufpp, const int first_addr,
130 const int second_addr, const bool match );
131 bool extract_subst_tail( const char ** const ibufpp, int * const gflagsp,
132 int * const snump, const bool isglobal );
133 int next_matching_node_addr( const char ** const ibufpp, const bool forward );
134 bool new_compiled_pattern( const char ** const ibufpp );
135 bool prev_pattern( void );
136 bool search_and_replace( const int first_addr, const int second_addr,
137 const int gflags, const int snum, const bool isglobal );
139 /* defined in signal.c */
140 void disable_interrupts( void );
141 void enable_interrupts( void );
142 bool parse_int( int * const i, const char * const str, const char ** const tail );
143 bool resize_buffer( char ** const buf, int * const size, const int min_size );
144 bool resize_line_buffer( const line_t *** const buf, int * const size,
145 const int min_size );
146 bool resize_undo_buffer( undo_t ** const buf, int * const size,
147 const int min_size );
148 void set_signals( void );
149 void set_window_lines( const int lines );
150 const char * strip_escapes( const char * p );
151 int window_columns( void );
152 int window_lines( void );