editor: add option to show EOL
[midnight-commander.git] / src / editor / editdraw.c
blobda09e95cc718cc121ded61b1652c5f7cd4e24db4
1 /* editor text drawing.
3 Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
4 2007 Free Software Foundation, Inc.
6 Authors: 1996, 1997 Paul Sheer
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
24 /** \file
25 * \brief Source: editor text drawing
26 * \author Paul Sheer
27 * \date 1996, 1997
30 #include <config.h>
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <sys/types.h>
35 #include <unistd.h>
36 #include <string.h>
37 #include <ctype.h>
38 #include <errno.h>
39 #include <sys/stat.h>
41 #include "lib/global.h"
42 #include "lib/tty/tty.h" /* tty_printf() */
43 #include "lib/tty/key.h" /* is_idle() */
44 #include "lib/skin.h"
45 #include "lib/strutil.h" /* utf string functions */
46 #include "lib/util.h" /* is_printable() */
47 #include "lib/widget.h" /* buttonbar_redraw() */
48 #include "lib/charsets.h"
50 #include "src/setup.h" /* edit_tab_spacing */
52 #include "edit-impl.h"
53 #include "edit-widget.h"
55 /*** global variables ****************************************************************************/
57 /* Toggles statusbar draw style */
58 int simple_statusbar = 0;
60 int visible_tabs = 1, visible_tws = 1, visible_eol = 0;
62 /*** file scope macro definitions ****************************************************************/
64 #define MAX_LINE_LEN 1024
66 /* Text styles */
67 #define MOD_ABNORMAL (1 << 8)
68 #define MOD_BOLD (1 << 9)
69 #define MOD_MARKED (1 << 10)
70 #define MOD_CURSOR (1 << 11)
71 #define MOD_WHITESPACE (1 << 12)
73 #define FONT_OFFSET_X 0
74 #define FONT_OFFSET_Y 0
75 #define FIXED_FONT 1
76 #define FONT_PIX_PER_LINE 1
77 #define FONT_MEAN_WIDTH 1
79 #define edit_move(x,y) widget_move(edit, y, x);
81 #define key_pending(x) (!is_idle())
84 /*** file scope type declarations ****************************************************************/
86 struct line_s
88 unsigned int ch;
89 unsigned int style;
92 /*** file scope variables ************************************************************************/
94 /*** file scope functions ************************************************************************/
95 /* --------------------------------------------------------------------------------------------- */
97 static inline void
98 status_string (WEdit * edit, char *s, int w)
100 char byte_str[16];
101 unsigned char cur_byte = 0;
102 unsigned int cur_utf = 0;
103 int cw = 1;
106 * If we are at the end of file, print <EOF>,
107 * otherwise print the current character as is (if printable),
108 * as decimal and as hex.
110 if (edit->curs1 < edit->last_byte)
112 if (!edit->utf8)
114 cur_byte = edit_get_byte (edit, edit->curs1);
116 g_snprintf (byte_str, sizeof (byte_str), "%4d 0x%03X",
117 (int) cur_byte, (unsigned) cur_byte);
119 else
121 cur_utf = edit_get_utf (edit, edit->curs1, &cw);
122 if (cw > 0)
124 g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
125 (unsigned) cur_utf, (unsigned) cur_utf);
127 else
129 cur_utf = edit_get_byte (edit, edit->curs1);
130 g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
131 (int) cur_utf, (unsigned) cur_utf);
136 else
138 strcpy (byte_str, "<EOF> ");
141 /* The field lengths just prevent the status line from shortening too much */
142 if (simple_statusbar)
143 g_snprintf (s, w,
144 "%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s",
145 edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
146 edit->modified ? 'M' : '-',
147 macro_index < 0 ? '-' : 'R',
148 edit->overwrite == 0 ? '-' : 'O',
149 edit->curs_col + edit->over_col,
150 edit->curs_line + 1,
151 edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
152 #ifdef HAVE_CHARSET
153 mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : ""
154 #else
156 #endif
158 else
159 g_snprintf (s, w,
160 "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s %s",
161 edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
162 edit->modified ? 'M' : '-',
163 macro_index < 0 ? '-' : 'R',
164 edit->overwrite == 0 ? '-' : 'O',
165 edit->curs_col + edit->over_col,
166 edit->start_line + 1,
167 edit->curs_row,
168 edit->curs_line + 1,
169 edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
170 #ifdef HAVE_CHARSET
171 mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : ""
172 #else
174 #endif
178 /* --------------------------------------------------------------------------------------------- */
180 static inline void
181 printwstr (const char *s, int len)
183 if (len > 0)
184 tty_printf ("%-*.*s", len, len, s);
187 /* --------------------------------------------------------------------------------------------- */
189 static inline void
190 print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
191 long end_col, struct line_s line[], char *status, int bookmarked)
193 struct line_s *p;
195 int x = start_col_real;
196 int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
197 int y = row + EDIT_TEXT_VERTICAL_OFFSET;
198 int cols_to_skip = abs (x);
199 int i;
201 tty_setcolor (EDITOR_NORMAL_COLOR);
202 if (bookmarked != 0)
203 tty_setcolor (bookmarked);
205 if (!show_right_margin)
207 tty_draw_hline (edit->widget.y + y, edit->widget.x + x1, ' ', end_col + 1 - start_col);
209 else if (edit->start_col < option_word_wrap_line_length)
211 tty_draw_hline (edit->widget.y + y,
212 edit->widget.x + x1, ' ', option_word_wrap_line_length - edit->start_col);
214 tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
215 tty_draw_hline (edit->widget.y + y,
216 edit->widget.x + x1 + option_word_wrap_line_length + edit->start_col,
217 ' ', end_col + 1 - start_col);
220 if (option_line_state)
222 for (i = 0; i < LINE_STATE_WIDTH; i++)
223 if (status[i] == '\0')
224 status[i] = ' ';
226 tty_setcolor (LINE_STATE_COLOR);
227 edit_move (x1 + FONT_OFFSET_X - option_line_state_width, y + FONT_OFFSET_Y);
228 tty_print_string (status);
231 edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y);
232 p = line;
233 i = 1;
234 while (p->ch)
236 int style;
237 unsigned int textchar;
238 int color;
240 if (cols_to_skip)
242 p++;
243 cols_to_skip--;
244 continue;
247 style = p->style & 0xFF00;
248 textchar = p->ch;
249 color = p->style >> 16;
251 if (style & MOD_ABNORMAL)
253 /* Non-printable - use black background */
254 color = 0;
257 if (style & MOD_WHITESPACE)
259 if (style & MOD_MARKED)
261 textchar = ' ';
262 tty_setcolor (EDITOR_MARKED_COLOR);
264 else
266 #if 0
267 if (color != EDITOR_NORMAL_COLOR)
269 textchar = ' ';
270 tty_lowlevel_setcolor (color);
272 else
273 #endif
274 tty_setcolor (EDITOR_WHITESPACE_COLOR);
277 else
279 if (style & MOD_BOLD)
281 tty_setcolor (EDITOR_BOLD_COLOR);
283 else if (style & MOD_MARKED)
285 tty_setcolor (EDITOR_MARKED_COLOR);
287 else
289 tty_lowlevel_setcolor (color);
292 if (show_right_margin)
294 if (i > option_word_wrap_line_length + edit->start_col)
295 tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
296 i++;
298 tty_print_anychar (textchar);
299 p++;
303 /* --------------------------------------------------------------------------------------------- */
304 /** b is a pointer to the beginning of the line */
306 static void
307 edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_col)
309 struct line_s line[MAX_LINE_LEN];
310 struct line_s *p = line;
312 long m1 = 0, m2 = 0, q, c1, c2;
313 int col, start_col_real;
314 unsigned int c;
315 int color;
316 int abn_style;
317 int i;
318 int utf8lag = 0;
319 unsigned int cur_line = 0;
320 int book_mark = 0;
321 char line_stat[LINE_STATE_WIDTH + 1];
323 if (row > edit->widget.lines - EDIT_TEXT_VERTICAL_OFFSET)
324 return;
326 if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_COLOR))
327 book_mark = BOOK_MARK_COLOR;
328 else if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_FOUND_COLOR))
329 book_mark = BOOK_MARK_FOUND_COLOR;
331 if (book_mark)
332 abn_style = book_mark << 16;
333 else
334 abn_style = MOD_ABNORMAL;
336 end_col -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
338 edit_get_syntax_color (edit, b - 1, &color);
339 q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
340 start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
341 if (option_line_state)
343 cur_line = edit->start_line + row;
344 if (cur_line <= (unsigned int) edit->total_lines)
346 g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
348 else
350 memset (line_stat, ' ', LINE_STATE_WIDTH);
351 line_stat[LINE_STATE_WIDTH] = '\0';
353 if (book_mark_query_color (edit, cur_line, BOOK_MARK_COLOR))
355 g_snprintf (line_stat, 2, "*");
359 if (col + 16 > -edit->start_col)
361 eval_marks (edit, &m1, &m2);
363 if (row <= edit->total_lines - edit->start_line)
365 long tws = 0;
366 if (tty_use_colors () && visible_tws)
368 tws = edit_eol (edit, b);
369 while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' ' || c == '\t'))
370 tws--;
373 while (col <= end_col - edit->start_col)
375 int cw = 1;
377 p->ch = 0;
378 p->style = 0;
379 if (q == edit->curs1)
380 p->style |= MOD_CURSOR;
381 if (q >= m1 && q < m2)
383 if (edit->column_highlight)
385 int x;
386 x = edit_move_forward3 (edit, b, 0, q);
387 c1 = min (edit->column1, edit->column2);
388 c2 = max (edit->column1, edit->column2);
389 if (x >= c1 && x < c2)
390 p->style |= MOD_MARKED;
392 else
393 p->style |= MOD_MARKED;
395 if (q == edit->bracket)
396 p->style |= MOD_BOLD;
397 if (q >= edit->found_start && q < edit->found_start + edit->found_len)
398 p->style |= MOD_BOLD;
400 if (!edit->utf8)
402 c = edit_get_byte (edit, q);
404 else
406 c = edit_get_utf (edit, q, &cw);
408 /* we don't use bg for mc - fg contains both */
409 if (book_mark)
411 p->style |= book_mark << 16;
413 else
415 edit_get_syntax_color (edit, q, &color);
416 p->style |= color << 16;
418 switch (c)
420 case '\n':
421 col = (end_col + utf8lag) - edit->start_col + 1; /* quit */
422 if (tty_use_colors() && visible_eol) {
423 p->ch = widget_edit_eol_char;
424 p->style |= MOD_WHITESPACE;
425 ++p;
426 ++col;
428 break;
429 case '\t':
430 i = TAB_SIZE - ((int) col % TAB_SIZE);
431 col += i;
432 if (tty_use_colors () &&
433 ((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws))
435 if (p->style & MOD_MARKED)
436 c = p->style;
437 else if (book_mark)
438 c |= book_mark << 16;
439 else
440 c = p->style | MOD_WHITESPACE;
441 if (i > 2)
443 p->ch = widget_edit_tab_first;
444 p->style = c;
445 p++;
446 while (--i > 1)
448 p->ch = widget_edit_tab_middle;
449 p->style = c;
450 p++;
452 p->ch = widget_edit_tab_last;
453 p->style = c;
454 p++;
456 else if (i > 1)
458 p->ch = widget_edit_tab_first;
459 p->style = c;
460 p++;
461 p->ch = widget_edit_tab_last;
462 p->style = c;
463 p++;
465 else
467 p->ch = widget_edit_tab_last;
468 p->style = c;
469 p++;
472 else if (tty_use_colors () && visible_tws && q >= tws && enable_show_tabs_tws)
474 p->ch = '.';
475 p->style |= MOD_WHITESPACE;
476 c = p->style & ~MOD_CURSOR;
477 p++;
478 while (--i)
480 p->ch = ' ';
481 p->style = c;
482 p++;
485 else
487 p->ch |= ' ';
488 c = p->style & ~MOD_CURSOR;
489 p++;
490 while (--i)
492 p->ch = ' ';
493 p->style = c;
494 p++;
497 break;
498 case ' ':
499 if (tty_use_colors () && visible_tws && q >= tws && enable_show_tabs_tws)
501 p->ch = '.';
502 p->style |= MOD_WHITESPACE;
503 p++;
504 col++;
505 break;
507 /* fallthrough */
508 default:
509 #ifdef HAVE_CHARSET
510 if (mc_global.utf8_display)
512 if (!edit->utf8)
514 c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
517 else if (edit->utf8)
518 c = convert_from_utf_to_current_c (c, edit->converter);
519 else
520 #endif
521 c = convert_to_display_c (c);
523 /* Caret notation for control characters */
524 if (c < 32)
526 p->ch = '^';
527 p->style = abn_style;
528 p++;
529 p->ch = c + 0x40;
530 p->style = abn_style;
531 p++;
532 col += 2;
533 break;
535 if (c == 127)
537 p->ch = '^';
538 p->style = abn_style;
539 p++;
540 p->ch = '?';
541 p->style = abn_style;
542 p++;
543 col += 2;
544 break;
546 if (!edit->utf8)
548 if ((mc_global.utf8_display && g_unichar_isprint (c)) ||
549 (!mc_global.utf8_display && is_printable (c)))
551 p->ch = c;
552 p++;
554 else
556 p->ch = '.';
557 p->style = abn_style;
558 p++;
561 else
563 if (g_unichar_isprint (c))
565 p->ch = c;
566 p++;
568 else
570 p->ch = '.';
571 p->style = abn_style;
572 p++;
575 col++;
576 break;
577 } /* case */
579 q++;
580 if (cw > 1)
582 q += cw - 1;
587 else
589 start_col_real = start_col = 0;
592 p->ch = '\0';
594 print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat, book_mark);
597 /* --------------------------------------------------------------------------------------------- */
599 static inline void
600 edit_draw_this_char (WEdit * edit, long curs, long row)
602 int b = edit_bol (edit, curs);
603 edit_draw_this_line (edit, b, row, 0, edit->widget.cols - 1);
606 /* --------------------------------------------------------------------------------------------- */
607 /** cursor must be in screen for other than REDRAW_PAGE passed in force */
609 static inline void
610 render_edit_text (WEdit * edit, long start_row, long start_column, long end_row, long end_column)
612 long row = 0, curs_row;
613 static long prev_curs_row = 0;
614 static long prev_curs = 0;
616 int force = edit->force;
617 long b;
620 * If the position of the page has not moved then we can draw the cursor
621 * character only. This will prevent line flicker when using arrow keys.
623 if ((!(force & REDRAW_CHAR_ONLY)) || (force & REDRAW_PAGE))
625 if (!(force & REDRAW_IN_BOUNDS))
626 { /* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */
627 start_row = 0;
628 end_row = edit->widget.lines - 1;
629 start_column = 0;
630 end_column = edit->widget.cols - 1;
632 if (force & REDRAW_PAGE)
634 row = start_row;
635 b = edit_move_forward (edit, edit->start_display, start_row, 0);
636 while (row <= end_row)
638 if (key_pending (edit))
639 return;
640 edit_draw_this_line (edit, b, row, start_column, end_column);
641 b = edit_move_forward (edit, b, 1, 0);
642 row++;
645 else
647 curs_row = edit->curs_row;
649 if (force & REDRAW_BEFORE_CURSOR)
651 if (start_row < curs_row)
653 long upto = curs_row - 1 <= end_row ? curs_row - 1 : end_row;
654 row = start_row;
655 b = edit->start_display;
656 while (row <= upto)
658 if (key_pending (edit))
659 return;
660 edit_draw_this_line (edit, b, row, start_column, end_column);
661 b = edit_move_forward (edit, b, 1, 0);
665 /* if (force & REDRAW_LINE) ---> default */
666 b = edit_bol (edit, edit->curs1);
667 if (curs_row >= start_row && curs_row <= end_row)
669 if (key_pending (edit))
670 return;
671 edit_draw_this_line (edit, b, curs_row, start_column, end_column);
673 if (force & REDRAW_AFTER_CURSOR)
675 if (end_row > curs_row)
677 row = curs_row + 1 < start_row ? start_row : curs_row + 1;
678 b = edit_move_forward (edit, b, 1, 0);
679 while (row <= end_row)
681 if (key_pending (edit))
682 return;
683 edit_draw_this_line (edit, b, row, start_column, end_column);
684 b = edit_move_forward (edit, b, 1, 0);
685 row++;
689 if (force & REDRAW_LINE_ABOVE && curs_row >= 1)
691 row = curs_row - 1;
692 b = edit_move_backward (edit, edit_bol (edit, edit->curs1), 1);
693 if (row >= start_row && row <= end_row)
695 if (key_pending (edit))
696 return;
697 edit_draw_this_line (edit, b, row, start_column, end_column);
700 if (force & REDRAW_LINE_BELOW && row < edit->widget.lines - 1)
702 row = curs_row + 1;
703 b = edit_bol (edit, edit->curs1);
704 b = edit_move_forward (edit, b, 1, 0);
705 if (row >= start_row && row <= end_row)
707 if (key_pending (edit))
708 return;
709 edit_draw_this_line (edit, b, row, start_column, end_column);
714 else
716 if (prev_curs_row < edit->curs_row)
717 { /* with the new text highlighting, we must draw from the top down */
718 edit_draw_this_char (edit, prev_curs, prev_curs_row);
719 edit_draw_this_char (edit, edit->curs1, edit->curs_row);
721 else
723 edit_draw_this_char (edit, edit->curs1, edit->curs_row);
724 edit_draw_this_char (edit, prev_curs, prev_curs_row);
728 edit->force = 0;
730 prev_curs_row = edit->curs_row;
731 prev_curs = edit->curs1;
734 /* --------------------------------------------------------------------------------------------- */
736 static inline void
737 edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end)
739 if (page) /* if it was an expose event, 'page' would be set */
740 edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS;
742 if (edit->force & REDRAW_COMPLETELY)
743 buttonbar_redraw (find_buttonbar (edit->widget.owner));
744 render_edit_text (edit, row_start, col_start, row_end, col_end);
746 * edit->force != 0 means a key was pending and the redraw
747 * was halted, so next time we must redraw everything in case stuff
748 * was left undrawn from a previous key press.
750 if (edit->force)
751 edit->force |= REDRAW_PAGE;
754 /* --------------------------------------------------------------------------------------------- */
755 /*** public functions ****************************************************************************/
756 /* --------------------------------------------------------------------------------------------- */
758 /** Draw the status line at the top of the widget. The size of the filename
759 * field varies depending on the width of the screen and the length of
760 * the filename. */
761 void
762 edit_status (WEdit * edit)
764 const int w = edit->widget.cols;
765 const size_t status_size = w + 1;
766 char *const status = g_malloc (status_size);
767 int status_len;
768 const char *fname = "";
769 int fname_len;
770 const int gap = 3; /* between the filename and the status */
771 const int right_gap = 5; /* at the right end of the screen */
772 const int preferred_fname_len = 16;
774 status_string (edit, status, status_size);
775 status_len = (int) str_term_width1 (status);
777 if (edit->filename)
778 fname = edit->filename;
779 fname_len = str_term_width1 (fname);
780 if (fname_len < preferred_fname_len)
781 fname_len = preferred_fname_len;
783 if (fname_len + gap + status_len + right_gap >= w)
785 if (preferred_fname_len + gap + status_len + right_gap >= w)
786 fname_len = preferred_fname_len;
787 else
788 fname_len = w - (gap + status_len + right_gap);
789 fname = str_trunc (fname, fname_len);
792 widget_move (edit, 0, 0);
793 tty_setcolor (STATUSBAR_COLOR);
794 printwstr (fname, fname_len + gap);
795 printwstr (status, w - (fname_len + gap));
797 if (simple_statusbar && edit->widget.cols > 30)
799 size_t percent;
800 if (edit->total_lines + 1 != 0)
801 percent = (edit->curs_line + 1) * 100 / (edit->total_lines + 1);
802 else
803 percent = 100;
804 widget_move (edit, 0, edit->widget.cols - 5);
805 tty_printf (" %3d%%", percent);
808 g_free (status);
811 /* --------------------------------------------------------------------------------------------- */
812 /** this scrolls the text so that cursor is on the screen */
813 void
814 edit_scroll_screen_over_cursor (WEdit * edit)
816 int p;
817 int outby;
818 int b_extreme, t_extreme, l_extreme, r_extreme;
820 if (edit->widget.lines <= 0 || edit->widget.cols <= 0)
821 return;
823 edit->widget.cols -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
824 edit->widget.lines -= EDIT_TEXT_VERTICAL_OFFSET - 1;
826 r_extreme = EDIT_RIGHT_EXTREME;
827 l_extreme = EDIT_LEFT_EXTREME;
828 b_extreme = EDIT_BOTTOM_EXTREME;
829 t_extreme = EDIT_TOP_EXTREME;
830 if (edit->found_len)
832 b_extreme = max (edit->widget.lines / 4, b_extreme);
833 t_extreme = max (edit->widget.lines / 4, t_extreme);
835 if (b_extreme + t_extreme + 1 > edit->widget.lines)
837 int n;
838 n = b_extreme + t_extreme;
839 b_extreme = (b_extreme * (edit->widget.lines - 1)) / n;
840 t_extreme = (t_extreme * (edit->widget.lines - 1)) / n;
842 if (l_extreme + r_extreme + 1 > edit->widget.cols)
844 int n;
845 n = l_extreme + t_extreme;
846 l_extreme = (l_extreme * (edit->widget.cols - 1)) / n;
847 r_extreme = (r_extreme * (edit->widget.cols - 1)) / n;
849 p = edit_get_col (edit) + edit->over_col;
850 edit_update_curs_row (edit);
851 outby = p + edit->start_col - edit->widget.cols + 1 + (r_extreme + edit->found_len);
852 if (outby > 0)
853 edit_scroll_right (edit, outby);
854 outby = l_extreme - p - edit->start_col;
855 if (outby > 0)
856 edit_scroll_left (edit, outby);
857 p = edit->curs_row;
858 outby = p - edit->widget.lines + 1 + b_extreme;
859 if (outby > 0)
860 edit_scroll_downward (edit, outby);
861 outby = t_extreme - p;
862 if (outby > 0)
863 edit_scroll_upward (edit, outby);
864 edit_update_curs_row (edit);
866 edit->widget.lines += EDIT_TEXT_VERTICAL_OFFSET - 1;
867 edit->widget.cols += EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
870 /* --------------------------------------------------------------------------------------------- */
872 void
873 edit_render_keypress (WEdit * edit)
875 edit_render (edit, 0, 0, 0, 0, 0);
878 /* --------------------------------------------------------------------------------------------- */