2016-10-13 01:28:04 +02:00
# ifndef KOLIBRI_EDITOR_H
# define KOLIBRI_EDITOR_H
// (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> + 2)
# define TE_MAXCHARS 100002
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
# define TE_MAX_SYNTAX_FILESIZE 410000
// buffer for copy|paste
# define TE_BUF_SIZE 4096
typedef void ( * editor_callback ) ( void ) ;
struct __attribute__ ( ( __packed__ ) ) editor_symbol {
uint8_t c ; // +0 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t col ; // +1 <20> <> <EFBFBD> <EFBFBD>
struct editor_symbol * prev ; // +2
struct editor_symbol * next ; // +6 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t tc ; // +10 <20> <> <EFBFBD> <EFBFBD> . <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t td ; // +14 <20> <> <EFBFBD> <EFBFBD> . <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
} ;
/// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
typedef struct __attribute__ ( ( __packed__ ) ) {
uint32_t x_pos ; //0
uint32_t y_pos ; //50
uint32_t width ; //440
uint32_t hight ; //150
2016-10-20 19:13:23 +02:00
uint32_t w_pane ; //30 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> , width of left pane with line numbers
uint32_t h_pane ; //25 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> , hight of top pane with Rows, Cols Undo info
2016-10-13 01:28:04 +02:00
uint32_t width_sym ; //9 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) <20> <20> <> <EFBFBD> <EFBFBD>
uint32_t hight_sym ; //16 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) <20> <20> <> <EFBFBD> <EFBFBD>
uint8_t drag_m ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD>
uint8_t drag_k ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t sel_x0 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t sel_y0 ;
uint32_t sel_x1 ;
uint32_t sel_y1 ;
uint32_t seln_x0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t seln_y0 ;
uint32_t seln_x1 ;
uint32_t seln_y1 ;
struct editor_symbol * tex ; // text memory pointer
struct editor_symbol * tex_1 ; // text first symbol pointer
struct editor_symbol * tex_end ; // text end memory pointer
uint32_t cur_x ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> x <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t cur_y ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> y <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t max_chars ; // TE_MAXCHARS ;+86 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t count_colors_text ; // 1 ;+90 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t count_key_words ; //+94 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
color_t color_cursor ; // 0x808080 ;+98 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
color_t color_wnd_capt ; // 0x80 ;+102 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
color_t color_wnd_work ; // 0x0 ;+106 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
color_t color_wnd_bord ; //0xd0d0d0 ;+110 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD>
color_t color_select ; // 0x208080 ;+114 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
color_t color_cur_text ; // 0xff0000 ;+118 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
color_t color_wnd_text ; // 0xffff00 ;+122 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD>
char * syntax_file ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t syntax_file_size ; // TE_MAX_SYNTAX_FILESIZE ;+130 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void * text_colors ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
char * help_text_f1 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> F1)
int help_id ; // -1 ;+142 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void * key_words_data ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> TexColViv
uint32_t tim_ch ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t tim_undo ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t tim_ls ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t tim_co ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void * el_focus ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> pointer to pointer**
uint8_t err_save ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t panel_id ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t key_new ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> , <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t symbol_new_line ; // ascii 20 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
scrollbar * scr_w ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> != NULL
scrollbar * scr_h ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> != NULL
char * arr_key_pos ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
char * buffer ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> != NULL, also size
char * buffer_find ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (sized 302)
uint8_t cur_ins ; // 1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
uint8_t mode_color ; // 1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (0-<2D> <> <EFBFBD> <EFBFBD> . 1-<2D> <> <EFBFBD> .)
uint8_t mode_invis ; // 0 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t gp_opt ; // 0 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ted_get_pos_by_cursor
editor_callback fun_on_key_ctrl_o ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ctrl+O (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ), can be NULL
editor_callback fun_on_key_ctrl_f ; // ... Ctrl+F (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
editor_callback fun_on_key_ctrl_n ; // ... Ctrl+N (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
editor_callback fun_on_key_ctrl_s ; // ... Ctrl+S
uint32_t buffer_size ; // BUF_SIZE <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_find_err ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_init_synt_err ; // unused <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_draw_panel_buttons ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_draw_panel_find ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_draw_panel_syntax ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
editor_callback fun_save_err ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t increase_size ; //200 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void * ptr_free_symb ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t font_size ; // ;+250 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> // binary OR mask for ECX SysFn4
} editor ;
struct __attribute__ ( ( __packed__ ) ) editor_color_item
{
char word [ 40 ] ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint32_t f1_offset ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> F1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t flags ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uint8_t endc ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> flags&4)
uint8_t escc ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> flags&4) ascii(34) <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \r \n \t
uint8_t color ; // <20> <> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
} ;
struct editor_syntax_file
{
uint32_t count_colors_text ; // <20> <> <EFBFBD> -<2D> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> dd (text-color_wnd_text)/4
uint32_t count_key_words ; // <20> <> <EFBFBD> -<2D> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> dd (f1-text)/48
color_t color_cursor ; // dd 0xf1fcd0
color_t color_wnd_capt ; // dd 0x080808
color_t color_wnd_work ; // dd 0x1C1C1C
color_t color_wnd_bord ; // dd 0xc0c0c0
color_t color_select ; // dd 0x3E3D32
color_t color_cur_text ; // dd 0x808080
color_t color_wnd_text [ ] ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> count_colors_text
// editor_color_item[]; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> count_key_words
} ;
static struct editor_syntax_file default_syntax = {
10 , //count_colors_text
2016-10-17 00:29:26 +02:00
1 , // count_key_words dd (f1-text)/48, minimum 1
2016-10-13 01:28:04 +02:00
0xf1fcd0 , //color_cursor dd 0xf1fcd0
0x080808 , //color_wnd_capt dd 0x080808
0x1C1C1C , //color_wnd_work dd 0x1C1C1C
0xc0c0c0 , //color_wnd_bord dd 0xc0c0c0
0x3E3D32 , //color_select dd 0x3E3D32
0x808080 , //color_cur_text dd 0x808080
{ 0xD0D0D0 , 0xffff00 , 0x00ff00 , 0x00ffff , 0x808080 , 0xff40ff , 0x4080ff , 0xff0000 , 0x8080ff , 0x00ccff }
} ;
// next structure must follow syntax definition, at least has 1 element !!!
static struct editor_color_item word1 = {
" siemargl " , 1 , 0 , 0 , 1 // test word colored as 1st in table
} ;
// next structure preferably follow syntax definition, at least has 1 element !!!
static char f1_table [ ] = {
" \0 "
" First \0 "
" Last \0 "
} ;
extern void ( * ted_draw ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
extern void ( * ted_init_scroll_bars ) ( editor * , int opt ) __attribute__ ( ( __stdcall__ ) ) ;
/// opt bits = 1 - <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> , 2 - <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> , 4 - <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
extern void ( * ted_init_syntax_file ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
extern void ( * ted_mouse ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
extern void ( * ted_text_add ) ( editor * , char * text , int textlen , int opt ) __attribute__ ( ( __stdcall__ ) ) ;
/// add text to cursor pos
/// opt == ted_opt_ed_change_time, ted_opt_ed_move_cursor
///ted_opt_ed_move_cursor equ 1 ;<3B> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
///ted_opt_ed_change_time equ 2 ;<3B> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
extern void ( * ted_but_select_word ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
/// select word under cursor
extern void ( * ted_but_copy ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
extern void ( * ted_but_paste ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
extern void ( * ted_but_find_next ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
///move cursor to <ed_buffer_find>, calls ted_fun_find_err() if exist
extern void ( * ted_but_sumb_upper_asm ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_selected_toupper ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t "
" push %%esi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_sumb_upper_asm ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%esi \n \t "
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_but_sumb_lover_asm ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_selected_tolower ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t "
" push %%esi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_sumb_lover_asm ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%esi \n \t "
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_but_convert_by_table_asm ) ( editor * , char * table ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_convert_by_table ( editor * ed , char * table )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t "
" push %%esi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_convert_by_table_asm ) ( ed , table ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%esi \n \t "
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern int ( * ted_can_save_asm ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline int editor_can_save ( editor * ed )
2016-10-17 00:29:26 +02:00
/// return 1 if need to be saved (has changes), 0 otherwise
2016-10-13 01:28:04 +02:00
{
int ret ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_can_save_asm ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : " =a " ( ret ) : : ) ;
2016-10-13 01:28:04 +02:00
return ret ;
}
extern void ( * ted_clear_asm ) ( editor * , int ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_clear ( editor * ed , int all )
/// all==1 - clear all memory
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_clear_asm ) ( ed , all ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_delete_asm ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_delete ( editor * ed )
/// frees all memory (destroy)
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_delete_asm ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
free ( ed - > scr_w ) ;
free ( ed - > scr_h ) ;
free ( ed - > buffer ) ;
free ( ed - > buffer_find ) ;
}
extern void ( * ted_init_asm ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_init ( editor * ed )
/// allocate memory
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_init_asm ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern int ( * ted_is_select ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline int editor_is_select ( editor * ed )
/// return 1 if have selection
{
int ret ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%ebx \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_is_select ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%ebx \n \t " : " =a " ( ret ) : : ) ;
2016-10-13 01:28:04 +02:00
return ret ;
}
enum control_keys {
KM_SHIFT = 0x00010000 ,
KM_CTRL = 0x00020000 ,
KM_ALT = 0x00040000 ,
KM_NUMLOCK = 0x00080000
} ;
extern void ( * ted_key_asm ) ( editor * , char * table , int control ) __attribute__ ( ( __stdcall__ ) ) ;
2016-10-20 19:13:23 +02:00
static inline __attribute__ ( ( __stdcall__ ) ) void editor_keyboard ( editor * ed , char * table , enum control_keys control , int ch )
2016-10-13 01:28:04 +02:00
/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK,
/// ch = GET_KEY
/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT
{
2016-10-20 19:13:23 +02:00
__asm__ __volatile__ (
" push %4 \n \t "
" push %3 \n \t "
" push %2 \n \t "
" call *%1 \n \t " : : " a " ( ch ) , " m " ( ted_key_asm ) , " m " ( ed ) , " m " ( table ) , " m " ( control ) : ) ;
/*
2016-10-13 01:28:04 +02:00
__asm__ __volatile__ (
" nop \n \t " : : " a " ( ch ) : ) ;
( * ted_key_asm ) ( ed , table , control ) ;
2016-10-20 19:13:23 +02:00
*/
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_open_file_asm ) ( editor * , struct fs_dirinfo * , char * fname ) __attribute__ ( ( __stdcall__ ) ) ;
static inline int editor_openfile ( editor * ed , char * fname , int * readbytes )
/// returns errcode as SysFn70
{
int ret ;
struct fs_dirinfo di ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_open_file_asm ) ( ed , & di , fname ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : " =b " ( * readbytes ) , " =a " ( ret ) : : ) ;
2016-10-13 01:28:04 +02:00
return ret ;
}
extern void ( * ted_save_file_asm ) ( editor * , struct fs_dirinfo * , char * fname ) __attribute__ ( ( __stdcall__ ) ) ;
static inline int editor_savefile ( editor * ed , char * fname )
/// returns errcode, calls fun_save_err() if exists
{
struct fs_dirinfo di ;
( * ted_save_file_asm ) ( ed , & di , fname ) ;
return ed - > err_save ;
}
extern void ( * ted_but_cut ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_cut ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_cut ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_but_undo ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_undo ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_undo ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_but_redo ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_redo ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_redo ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_but_reverse ) ( editor * ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_reverse ( editor * ed )
{
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" push %%edi \n \t "
" push %%ebx \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
( * ted_but_reverse ) ( ed ) ;
__asm__ __volatile__ (
2016-10-17 00:29:26 +02:00
" pop %%ebx \n \t "
" pop %%edi \n \t " : : : ) ;
2016-10-13 01:28:04 +02:00
}
extern void ( * ted_text_colored_asm ) ( ) __attribute__ ( ( __stdcall__ ) ) ;
static inline void editor_text_colored ( editor * ed )
{
__asm__ __volatile__ (
" nop \n \t " : : " D " ( ed ) : ) ;
( * ted_text_colored_asm ) ( ) ;
}
static inline
uint32_t get_control_keys ( void )
{
uint32_t ctrl ;
__asm__ __volatile__ (
" int $0x40 \n \t "
: " =a " ( ctrl )
: " a " ( 66 ) , " b " ( 3 ) ) ;
return ctrl ;
} ;
static inline
int get_keyboard_layout ( int opt , char * buf )
/// 128 byte buffer
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language
{
uint32_t lang ;
__asm__ __volatile__ (
" int $0x40 \n \t "
: " =a " ( lang )
: " a " ( 26 ) , " b " ( 2 ) , " c " ( opt ) , " d " ( buf ) ) ;
return lang ;
} ;
2016-10-20 19:13:23 +02:00
__attribute__ ( ( __stdcall__ ) )
static void editor_key ( editor * ed , oskey_t key )
2016-10-13 01:28:04 +02:00
// callback for gui
{
2016-10-20 19:13:23 +02:00
//if(ed->el_focus != ed) return; // need to check not to lose keyb buffer
2016-10-13 01:28:04 +02:00
uint32_t control = get_control_keys ( ) ;
enum control_keys ed_ctrl = 0 ;
int ly_opt = 1 ;
if ( control & 3 ) { ed_ctrl | = KM_SHIFT ; ly_opt = 2 ; }
if ( control & 0xC ) ed_ctrl | = KM_CTRL ;
if ( control & 0x30 ) { ed_ctrl | = KM_ALT ; ly_opt = 3 ; }
if ( control & 0x80 ) ed_ctrl | = KM_NUMLOCK ;
char conv_table [ 128 ] ;
get_keyboard_layout ( ly_opt , conv_table ) ;
2016-10-20 19:13:23 +02:00
editor_keyboard ( ed , conv_table , ed_ctrl , key . val ) ;
2016-10-13 01:28:04 +02:00
}
2016-10-17 00:29:26 +02:00
static inline void gui_add_editor ( kolibri_window * wnd , editor * e )
2016-10-13 01:28:04 +02:00
{
kolibri_window_add_element ( wnd , KOLIBRI_EDITOR , e ) ;
}
2016-10-20 19:13:23 +02:00
static inline editor * kolibri_new_editor ( uint32_t x_w , uint32_t y_h , uint32_t font , uint32_t max_chars , void * editor_interlock )
2016-10-13 01:28:04 +02:00
/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1)
{
editor * ed = ( editor * ) calloc ( 1 , sizeof ( editor ) ) ;
ed - > x_pos = x_w > > 16 ;
ed - > width = x_w & 0xFFFF ;
ed - > y_pos = y_h > > 16 ;
ed - > hight = y_h & 0xFFFF ;
2016-10-20 19:13:23 +02:00
ed - > w_pane = 30 ;
ed - > h_pane = 20 ;
2016-10-13 01:28:04 +02:00
// font
if ( font = = 0 ) font = 0x10 ; // default 16 = 8x16
int font_multipl = ( font & 7 ) + 1 ;
ed - > font_size = font < < 24 ;
if ( font & 0x10 ) // 8x16
{
ed - > width_sym = 8 * font_multipl ;
ed - > hight_sym = 16 * font_multipl ;
} else // 6x9
{
ed - > width_sym = 6 * font_multipl ;
ed - > hight_sym = 9 * font_multipl ;
}
// memory sizing for text & syntax
ed - > max_chars = max_chars ;
ed - > increase_size = max_chars / 2 ;
ed - > syntax_file_size = sizeof ( default_syntax ) ;
/* // loaded auto from syntax
ed - > color_cursor = 0x808080 ;
ed - > color_wnd_capt = 0x80 ;
ed - > color_wnd_bord = 0xd0d0d0 ;
ed - > color_select = 0x208080 ;
ed - > color_cur_text = 0xff0000 ;
ed - > color_wnd_text = 0xffff00 ;
*/
ed - > symbol_new_line = 20 ; // ascii(20)
2016-10-20 19:13:23 +02:00
ed - > scr_w = kolibri_new_scrollbar_def ( X_Y ( 0 , 16 ) , X_Y ( 0 , 0 ) , 100 , 30 , 0 ) ; // cur_area will be inited ltr, max & pos undef
ed - > scr_h = kolibri_new_scrollbar_def ( X_Y ( 0 , 0 ) , X_Y ( 0 , 16 ) , 100 , 30 , 0 ) ; // cur_area will be inited ltr, max & pos undef
2016-10-13 01:28:04 +02:00
ed - > buffer_size = TE_BUF_SIZE ;
ed - > buffer = malloc ( TE_BUF_SIZE ) ;
ed - > buffer_find = malloc ( TE_BUF_SIZE / 8 ) ; //where to store text to search
ed - > cur_ins = 1 ; // insert mode default
ed - > mode_color = 1 ; // can select text
ed - > mode_invis = 1 ; // show nonprinted symbols
2016-10-20 19:13:23 +02:00
ed - > el_focus = editor_interlock ;
2016-10-13 01:28:04 +02:00
// ??? saveregs ax,cx,di
editor_init ( ed ) ; // memory allocation, cleaning
ed - > syntax_file = ( char * ) & default_syntax ;
( * ted_init_syntax_file ) ( ed ) ; // load colors and syntax highlight
ed - > help_text_f1 = f1_table ; // override if not aligned immediately after syntax words
ed - > key_words_data = & word1 ;
return ed ;
}
# endif // KOLIBRI_EDITOR_H