diff --git a/src/chars.c b/src/chars.c index c37aada6758d9fc26cbbb9aaadb06acf2b9d051f..a683177b0e5e602ab593686800f74f716483cf5c 100644 --- a/src/chars.c +++ b/src/chars.c @@ -234,8 +234,8 @@ char control_rep(const signed char c) /* Return the visible representation of multibyte control character c. */ char control_mbrep(const char *c, bool isdata) { - /* An embedded newline is an encoded null *if* it is data. */ - if (*c == '\n' && isdata) + /* An embedded newline is an encoded NUL if it is data. */ + if (*c == '\n' && (isdata || as_an_at)) return '@'; #ifdef ENABLE_UTF8 diff --git a/src/files.c b/src/files.c index b79238e579ba4b25a4dad2a4ccd66ad77919fd81..80245bbd89e4bb27b220fd5bb4e2c84ebe838792 100644 --- a/src/files.c +++ b/src/files.c @@ -1058,6 +1058,9 @@ void do_insertfile(void) bool execute = FALSE, right_side_up = FALSE, single_line = FALSE; #endif + /* Display embedded newlines as ^J. */ + as_an_at = FALSE; + while (TRUE) { #ifndef NANO_TINY if (execute) { @@ -2178,6 +2181,9 @@ int do_writeout(bool exiting) static bool did_credits = FALSE; #endif + /* Display embedded newlines as ^J. */ + as_an_at = FALSE; + if (exiting && ISSET(TEMP_FILE) && openfile->filename[0] != '\0') { if (write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE)) return 1; diff --git a/src/global.c b/src/global.c index 645c366814c517d341dd77eba135553e70d30421..3eb2c5c06e268510a69377f6a2a97027384ec8ee 100644 --- a/src/global.c +++ b/src/global.c @@ -45,6 +45,9 @@ bool shift_held; bool focusing = TRUE; /* Whether an update of the edit window should center the cursor. */ +bool as_an_at = TRUE; + /* Whether a 0x0A byte should be shown as a ^@ instead of a ^J. */ + int margin = 0; /* The amount of space reserved at the left for line numbers. */ int editwincols = -1; diff --git a/src/nano.c b/src/nano.c index cd181aa4cbaafd814bb765f9d106233038921009..5f1422b1b877198094e1122431a3467b3e65fb15 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2674,6 +2674,7 @@ int main(int argc, char **argv) display_main_list(); lastmessage = HUSH; + as_an_at = TRUE; /* Update the displayed current cursor position only when there * are no keys waiting in the input buffer. */ diff --git a/src/proto.h b/src/proto.h index 189ef7576698dddf1789b627956bacc25de1523b..5680c6edd475ed6d24d06a1605eb27ae28de226b 100644 --- a/src/proto.h +++ b/src/proto.h @@ -38,6 +38,8 @@ extern bool shift_held; extern bool focusing; +extern bool as_an_at; + extern int margin; extern int editwincols; diff --git a/src/search.c b/src/search.c index 7b50ca7af11131af69bb5d7fa3f74b991ac11003..59ef7a6d1fcfbe94b2abae194b9485e95d065e9a 100644 --- a/src/search.c +++ b/src/search.c @@ -743,6 +743,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, } set_modified(); + as_an_at = TRUE; numreplaced++; } } diff --git a/src/winio.c b/src/winio.c index c06b2481aaab8d25e6d13311625cd9f58e7838ef..555a05a4d221caf1cf7d3e9124f8d00c25034419 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1967,6 +1967,7 @@ void titlebar(const char *path) wattron(topwin, interface_color_pair[TITLE_BAR]); blank_titlebar(); + as_an_at = FALSE; /* Do as Pico: if there is not enough width available for all items, * first sacrifice the version string, then eat up the side spaces,