1 /*
2 
3 wineditline.h
4 
5 is part of:
6 
7 WinEditLine (formerly MinGWEditLine)
8 Copyright 2010-2020 Paolo Tosco <paolo.tosco.mail@gmail.com>
9 All rights reserved.
10 
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14 
15     * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17     * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20     * Neither the name of WinEditLine (formerly MinGWEditLine) nor the
21     name of its contributors may be used to endorse or promote products
22     derived from this software without specific prior written permission.
23 
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
25 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36 */
37 
38 
39 #ifndef _WINEDITLINE_H_
40 #define _WINEDITLINE_H_
41 
42 #include <windows.h>
43 
44 /*
45 these defines may be changed
46 */
47 #define _EL_BUF_LEN      4096  /* line buffer size increment */
48 
49 /*
50 these defines should not be mangled
51 */
52 #define _EL_CONSOLE_BUF_LEN    8
53 #define _EL_MIN_HIST_SIZE    1
54 #define _EL_ENV_BUF_LEN      64
55 #define _EL_MAX_FILE_BREAK_CHARACTERS  64
56 #define _EL_BASIC_FILE_BREAK_CHARACTERS  _T(" \"\t\n=><|")
57 #define _EL_BASIC_FILE_QUOTE_CHARACTERS  _T(" $;=&")
58 
59 /*
60 these are included because for some reason
61 they are missing from MinGW gcc 4.5.0
62 */
63 #ifndef ENABLE_EXTENDED_FLAGS
64 #define ENABLE_EXTENDED_FLAGS    0x0080
65 #endif
66 #ifndef ENABLE_INSERT_MODE
67 #define ENABLE_INSERT_MODE    0x0020
68 #endif
69 #ifndef ENABLE_QUICK_EDIT_MODE
70 #define ENABLE_QUICK_EDIT_MODE    0x0040
71 #endif
72 
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 /*
79 prototypes of internal functions
80 */
81 char **_el_alloc_array(int n, int size);
82 wchar_t *_el_mb2w(char *mb, wchar_t **w);
83 char *_el_w2mb(wchar_t *w, char **mb);
84 int _el_grow_buffers(size_t size);
85 void _el_free_array(void *array);
86 void _el_clean_exit();
87 int _el_insert_char(wchar_t *buf, int n);
88 int _el_delete_char(UINT32 vk, int n);
89 void _el_add_char(wchar_t *string, wchar_t c, int n);
90 int _el_pad(CONSOLE_SCREEN_BUFFER_INFO *sbInfo, wchar_t *_el_temp_print);
91 int _el_print_string(wchar_t *string);
92 int _el_move_cursor(UINT32 vk, UINT32 ctrl);
93 int _el_set_cursor(int offset);
94 void _el_remove_tail_spaces(char *line);
95 wchar_t *_el_get_compl_text(int *start, int *end);
96 int _el_check_root_identity(wchar_t *root, wchar_t *entry_name);
97 int _el_fn_qsort_string_compare(const void *i1, const void *i2);
98 void _el_display_history();
99 int _el_find_history_file(const char *filename, wchar_t **name);
100 int _el_write_history_helper(const char *filename, const wchar_t *mode, int nelements);
101 int _el_display_prev_hist();
102 int _el_display_next_hist();
103 int _el_display_first_hist();
104 int _el_display_last_hist();
105 HIST_ENTRY *_el_previous_history();
106 HIST_ENTRY *_el_next_history();
107 int _el_history_set_pos(int i);
108 BOOL _el_signal_handler(DWORD fdwCtrlType);
109 BOOL _el_replace_char(wchar_t *string, wchar_t src, wchar_t dest);
110 
111 extern wchar_t *_el_line_buffer;
112 extern wchar_t *_el_print;
113 extern wchar_t *_el_temp_print;
114 extern wchar_t *_el_next_compl;
115 extern wchar_t *_el_file_name;
116 extern wchar_t *_el_dir_name;
117 extern wchar_t *_el_old_arg;
118 extern wchar_t *_el_wide;
119 extern wchar_t *_el_text;
120 extern char *_el_text_mb;
121 extern wchar_t *_el_prompt;
122 extern wchar_t **_el_compl_array;
123 extern wchar_t *_el_basic_word_break_characters;
124 extern wchar_t *_el_completer_word_break_characters;
125 extern wchar_t _el_basic_file_break_characters[_EL_MAX_FILE_BREAK_CHARACTERS];
126 extern int _el_ctrl_c_pressed;
127 extern int _el_compl_index;
128 extern int _el_n_compl;
129 extern int _el_prompt_len;
130 extern BOOL _el_prev_in_cm_saved;
131 extern BOOL _el_prev_out_cm_saved;
132 extern DWORD _el_prev_in_cm;
133 extern DWORD _el_prev_out_cm;
134 extern HANDLE _el_h_in;
135 extern HANDLE _el_h_out;
136 extern COORD _el_prev_size;
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* _WINEDITLINE_H_ */
143