58
58
* @param term
59
59
* The guac_terminal whose cursor should be advanced to the next row.
60
60
*/
61
- static void guac_terminal_linefeed (guac_terminal * term ) {
61
+ static void guac_terminal_linefeed (guac_terminal * term , bool force_wrap ) {
62
+
63
+ /* Assign in column out of screen: 1 to avoid \n in clipboard or 0 to add \n */
64
+ guac_terminal_buffer_row * buffer_row =
65
+ guac_terminal_buffer_get_row (term -> buffer , term -> cursor_row , 0 );
66
+ buffer_row -> characters [buffer_row -> length ].value = force_wrap ? 1 : 0 ;
62
67
63
68
/* Scroll up if necessary */
64
69
if (term -> cursor_row == term -> scroll_end )
@@ -81,6 +86,11 @@ static void guac_terminal_linefeed(guac_terminal* term) {
81
86
*/
82
87
static void guac_terminal_reverse_linefeed (guac_terminal * term ) {
83
88
89
+ /* Reset column out of screen */
90
+ guac_terminal_buffer_row * buffer_row =
91
+ guac_terminal_buffer_get_row (term -> buffer , term -> cursor_row , 0 );
92
+ buffer_row -> characters [buffer_row -> length ].value = 0 ;
93
+
84
94
/* Scroll down if necessary */
85
95
if (term -> cursor_row == term -> scroll_start )
86
96
guac_terminal_scroll_down (term , term -> scroll_start ,
@@ -221,7 +231,7 @@ int guac_terminal_echo(guac_terminal* term, unsigned char c) {
221
231
case 0x0C : /* FF */
222
232
223
233
/* Advance to next row */
224
- guac_terminal_linefeed (term );
234
+ guac_terminal_linefeed (term , false );
225
235
226
236
/* If automatic carriage return, fall through to CR handler */
227
237
if (!term -> automatic_carriage_return )
@@ -269,8 +279,10 @@ int guac_terminal_echo(guac_terminal* term, unsigned char c) {
269
279
270
280
/* Wrap if necessary */
271
281
if (term -> cursor_col >= term -> term_width ) {
282
+
283
+ /* New line */
272
284
term -> cursor_col = 0 ;
273
- guac_terminal_linefeed (term );
285
+ guac_terminal_linefeed (term , true );
274
286
}
275
287
276
288
/* If insert mode, shift other characters right by 1 */
@@ -340,14 +352,14 @@ int guac_terminal_escape(guac_terminal* term, unsigned char c) {
340
352
341
353
/* Index (IND) */
342
354
case 'D' :
343
- guac_terminal_linefeed (term );
355
+ guac_terminal_linefeed (term , false );
344
356
term -> char_handler = guac_terminal_echo ;
345
357
break ;
346
358
347
359
/* Next Line (NEL) */
348
360
case 'E' :
349
361
guac_terminal_move_cursor (term , term -> cursor_row , 0 );
350
- guac_terminal_linefeed (term );
362
+ guac_terminal_linefeed (term , false );
351
363
term -> char_handler = guac_terminal_echo ;
352
364
break ;
353
365
0 commit comments