Fixed wordwrap bug in internal editor

This commit is contained in:
Andrew Pamment 2018-02-20 15:02:39 +10:00
parent edb7209a9b
commit c98ad14aef
6 changed files with 51 additions and 4 deletions

View File

@ -23,6 +23,10 @@ LINE: 277 NEW
OLDSTRING: (NONE) OLDSTRING: (NONE)
NEWSTRING: "\r\nScan for new personal mail? (Y/N/S): " NEWSTRING: "\r\nScan for new personal mail? (Y/N/S): "
LINE: 88 MODIFIED
OLDSTRING: "\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s"
NEWSTRING: "\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m"
Changes from v0.8-alpha -> v0.9-alpha Changes from v0.8-alpha -> v0.9-alpha
-------------------------------------------------------------- --------------------------------------------------------------
LINE: 255 NEW LINE: 255 NEW

View File

@ -86,7 +86,7 @@ Sorry, you don't have permission to upload in this Sub\r\n
\r\nUse external editor? (Y/N) \r\nUse external editor? (Y/N)
\r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n \r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m \e[1;30m-------------------------------------------------------------------------------\e[0m
\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s \r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m
\r\nNo message to quote!\r\n \r\nNo message to quote!\r\n
\r\nQuote from Line: \r\nQuote from Line:
\r\nQuote to Line: \r\nQuote to Line:

View File

@ -537,6 +537,49 @@ char s_getc() {
return (char)c; return (char)c;
} }
void s_readstring_inject(char *buffer, int max, char *inject) {
int i;
char c;
memset(buffer, 0, max);
if (strlen(inject) > max) {
return;
}
strcpy(buffer, inject);
s_printf("%s", inject);
for (i=strlen(buffer);i<max;i++) {
c = s_getchar();
if ((c == '\b' || c == 127) && i > 0) {
buffer[i-1] = '\0';
i -= 2;
s_printf("\e[D \e[D");
continue;
} else if (c == '\b' || c == 127) {
i -= 1;
continue;
} else if (c == 27) {
c = s_getchar();
if (c == 91) {
c = s_getchar();
}
i -= 1;
continue;
}
if (c == '\n' || c == '\r') {
return;
}
s_putchar(c);
buffer[i] = c;
buffer[i+1] = '\0';
}
}
void s_readstring(char *buffer, int max) { void s_readstring(char *buffer, int max) {
int i; int i;
char c; char c;

View File

@ -262,6 +262,7 @@ extern void s_displayansi(char *file);
extern char s_getchar(); extern char s_getchar();
extern void s_readpass(char *buffer, int max); extern void s_readpass(char *buffer, int max);
extern void s_readstring(char *buffer, int max); extern void s_readstring(char *buffer, int max);
extern void s_readstring_inject(char *buffer, int max, char *inject);
extern char s_getc(); extern char s_getc();
extern void disconnect(char *calledby); extern void disconnect(char *calledby);
extern void display_info(); extern void display_info();

View File

@ -621,9 +621,9 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
s_printf(get_string(87)); s_printf(get_string(87));
while(!doquit) { while(!doquit) {
s_printf(get_string(88), lines, next_line_buffer); s_printf(get_string(88), lines);
strcpy(linebuffer, next_line_buffer); strcpy(linebuffer, next_line_buffer);
s_readstring(&linebuffer[strlen(next_line_buffer)], 70 - strlen(next_line_buffer)); s_readstring_inject(linebuffer, 70, next_line_buffer);
memset(next_line_buffer, 0, 70); memset(next_line_buffer, 0, 70);
if (strlen(linebuffer) == 70 && linebuffer[69] != ' ') { if (strlen(linebuffer) == 70 && linebuffer[69] != ' ') {

View File

@ -859,7 +859,6 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
} else if (strcasecmp(url, "/files/areas/") == 0 || strcasecmp(url, "/files/areas") == 0) { } else if (strcasecmp(url, "/files/areas/") == 0 || strcasecmp(url, "/files/areas") == 0) {
page = www_files_areas(); page = www_files_areas();
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1); whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
sprintf(whole_page, "%s%s%s", header, page, footer); sprintf(whole_page, "%s%s%s", header, page, footer);
} else if (strncasecmp(url, "/files/areas/", 13) == 0) { } else if (strncasecmp(url, "/files/areas/", 13) == 0) {
file_dir = -1; file_dir = -1;