| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
#ifdef HAVE_CONFIG_H |
| 10 |
|
#include "config.h" |
| 11 |
|
#endif |
| 12 |
|
|
| 13 |
#include "bbs.h" |
#include "bbs.h" |
| 14 |
#include "common.h" |
#include "common.h" |
| 15 |
#include "editor.h" |
#include "editor.h" |
| 81 |
long line_offsets[MAX_EDITOR_DATA_LINES + 1]; |
long line_offsets[MAX_EDITOR_DATA_LINES + 1]; |
| 82 |
long current_data_line_length = 0; |
long current_data_line_length = 0; |
| 83 |
long i; |
long i; |
| 84 |
|
int j; |
| 85 |
|
|
| 86 |
if (p_data == NULL) |
if (p_data == NULL) |
| 87 |
{ |
{ |
| 128 |
memcpy(p_editor_data->p_display_lines[i], p_data + line_offsets[i], (size_t)p_editor_data->display_line_lengths[i]); |
memcpy(p_editor_data->p_display_lines[i], p_data + line_offsets[i], (size_t)p_editor_data->display_line_lengths[i]); |
| 129 |
current_data_line_length += p_editor_data->display_line_lengths[i]; |
current_data_line_length += p_editor_data->display_line_lengths[i]; |
| 130 |
|
|
| 131 |
|
// Convert \t to single space |
| 132 |
|
for (j = 0; j < p_editor_data->display_line_lengths[i]; j++) |
| 133 |
|
{ |
| 134 |
|
if (p_editor_data->p_display_lines[i][j] == '\t') |
| 135 |
|
{ |
| 136 |
|
p_editor_data->p_display_lines[i][j] = ' '; |
| 137 |
|
} |
| 138 |
|
} |
| 139 |
|
|
| 140 |
// Trim \n from last line |
// Trim \n from last line |
| 141 |
if (i + 1 == p_editor_data->display_line_total && |
if (i + 1 == p_editor_data->display_line_total && |
| 142 |
p_editor_data->display_line_lengths[i] > 0 && |
p_editor_data->display_line_lengths[i] > 0 && |
| 683 |
int i, j; |
int i, j; |
| 684 |
char *p_str; |
char *p_str; |
| 685 |
int del_line; |
int del_line; |
| 686 |
|
int tab_width = 0; |
| 687 |
|
|
| 688 |
clrline(output_current_row, SCREEN_ROWS); |
clrline(output_current_row, SCREEN_ROWS); |
| 689 |
|
|
| 722 |
moveto((int)row_pos, (int)col_pos); |
moveto((int)row_pos, (int)col_pos); |
| 723 |
iflush(); |
iflush(); |
| 724 |
|
|
| 725 |
|
tab_width = 0; |
| 726 |
str_len = 0; |
str_len = 0; |
| 727 |
ch = igetch_t(BBS_max_user_idle_time); |
ch = igetch_t(BBS_max_user_idle_time); |
| 728 |
while (!SYS_server_exit) |
while (!SYS_server_exit) |
| 738 |
goto cleanup; |
goto cleanup; |
| 739 |
} |
} |
| 740 |
|
|
| 741 |
|
if (ch == '\t') |
| 742 |
|
{ |
| 743 |
|
ch = ' '; |
| 744 |
|
tab_width = TAB_SIZE - ((int)(col_pos - 1) % TAB_SIZE) - 1; |
| 745 |
|
} |
| 746 |
|
|
| 747 |
if (ch < 256 && (ch & 0x80)) // head of multi-byte character |
if (ch < 256 && (ch & 0x80)) // head of multi-byte character |
| 748 |
{ |
{ |
| 749 |
str_len = 0; |
str_len = 0; |
| 862 |
break; |
break; |
| 863 |
} |
} |
| 864 |
|
|
| 865 |
ch = igetch(0); |
if (ch == ' ' && tab_width > 0) |
|
if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input |
|
| 866 |
{ |
{ |
| 867 |
break; |
tab_width--; |
| 868 |
|
} |
| 869 |
|
else |
| 870 |
|
{ |
| 871 |
|
ch = igetch(0); |
| 872 |
|
if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Output if no futher input |
| 873 |
|
{ |
| 874 |
|
break; |
| 875 |
|
} |
| 876 |
} |
} |
| 877 |
|
|
| 878 |
str_len = 0; |
str_len = 0; |
| 974 |
switch (ch) |
switch (ch) |
| 975 |
{ |
{ |
| 976 |
case KEY_NULL: |
case KEY_NULL: |
| 977 |
|
#ifdef _DEBUG |
| 978 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 979 |
|
#endif |
| 980 |
goto cleanup; |
goto cleanup; |
| 981 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 982 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |