| 22 |
#include "str_process.h" |
#include "str_process.h" |
| 23 |
#include "memory_pool.h" |
#include "memory_pool.h" |
| 24 |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <sys/param.h> |
|
|
#include <strings.h> |
|
|
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
| 25 |
#include <string.h> |
#include <string.h> |
| 26 |
|
#include <sys/param.h> |
| 27 |
|
|
| 28 |
#define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m" |
#define EDITOR_ESC_DISPLAY_STR "\033[32m*\033[m" |
| 29 |
#define EDITOR_MEM_POOL_LINE_PER_CHUNK 1000 |
#define EDITOR_MEM_POOL_LINE_PER_CHUNK 1000 |
| 135 |
p_data_line[current_data_line_length] = '\0'; |
p_data_line[current_data_line_length] = '\0'; |
| 136 |
} |
} |
| 137 |
|
|
| 138 |
bzero(p_editor_data->p_display_lines + p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES - (size_t)p_editor_data->display_line_total); |
memset(p_editor_data->p_display_lines + p_editor_data->display_line_total, 0, MAX_EDITOR_DATA_LINES - (size_t)p_editor_data->display_line_total); |
| 139 |
|
|
| 140 |
return p_editor_data; |
return p_editor_data; |
| 141 |
} |
} |
| 278 |
{ |
{ |
| 279 |
if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES) |
if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES) |
| 280 |
{ |
{ |
| 281 |
// log_error("Split line error, display_line_total(%ld) reach limit(%d)\n", |
#ifdef _DEBUG |
| 282 |
// p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES); |
log_error("Split line error, display_line_total(%ld) reach limit(%d)\n", |
| 283 |
|
p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES); |
| 284 |
|
#endif |
| 285 |
|
|
| 286 |
return -2; |
return -2; |
| 287 |
} |
} |
| 288 |
|
|
| 371 |
// Insert blank display line after last_display_line |
// Insert blank display line after last_display_line |
| 372 |
if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES) |
if (p_editor_data->display_line_total >= MAX_EDITOR_DATA_LINES) |
| 373 |
{ |
{ |
| 374 |
// log_error("display_line_total over limit %d >= %d\n", p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES); |
#ifdef _DEBUG |
| 375 |
|
log_error("display_line_total over limit %d >= %d\n", p_editor_data->display_line_total, MAX_EDITOR_DATA_LINES); |
| 376 |
|
#endif |
| 377 |
|
|
| 378 |
// Terminate prior display line with \n, to avoid error on cleanup |
// Terminate prior display line with \n, to avoid error on cleanup |
| 379 |
if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0) |
if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0) |
| 380 |
{ |
{ |
| 711 |
if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK |
if ((ch >= 32 && ch < 127) || (ch > 127 && ch <= 255 && str_len == 2) || // Printable character or GBK |
| 712 |
ch == CR || ch == KEY_ESC) // Special character |
ch == CR || ch == KEY_ESC) // Special character |
| 713 |
{ |
{ |
| 714 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 715 |
|
|
| 716 |
if (str_len == 0) // ch >= 32 && ch < 127 |
if (str_len == 0) // ch >= 32 && ch < 127 |
| 717 |
{ |
{ |
| 787 |
} |
} |
| 788 |
else if (ch == KEY_DEL || ch == BACKSPACE) // Del |
else if (ch == KEY_DEL || ch == BACKSPACE) // Del |
| 789 |
{ |
{ |
| 790 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 791 |
|
|
| 792 |
if (ch == BACKSPACE) |
if (ch == BACKSPACE) |
| 793 |
{ |
{ |
| 1064 |
break; |
break; |
| 1065 |
} |
} |
| 1066 |
|
|
| 1067 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 1068 |
|
|
| 1069 |
if (input_ok) |
if (input_ok) |
| 1070 |
{ |
{ |