Draw status line at the top of screen not at the top of editor widget.
[midnight-commander.git] / src / editor / editdraw.c
blobfcdf6fbca90a72b10e8fb837336da847ed7f2d07
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/main.h" /* source_codepage */
51 #include "src/setup.h" /* edit_tab_spacing */
53 #include "edit-impl.h"
54 #include "edit-widget.h"
56 /*** global variables ****************************************************************************/
58 /* Toggles statusbar draw style */
59 int simple_statusbar = 0;
61 int visible_tabs = 1, visible_tws = 1;
63 /*** file scope macro definitions ****************************************************************/
65 #define MAX_LINE_LEN 1024
67 /* Text styles */
68 #define MOD_ABNORMAL (1 << 8)
69 #define MOD_BOLD (1 << 9)
70 #define MOD_MARKED (1 << 10)
71 #define MOD_CURSOR (1 << 11)
72 #define MOD_WHITESPACE (1 << 12)
74 #define FONT_OFFSET_X 0
75 #define FONT_OFFSET_Y 0
76 #define FIXED_FONT 1
77 #define FONT_PIX_PER_LINE 1
78 #define FONT_MEAN_WIDTH 1
80 #define edit_move(x,y) widget_move(edit, y, x);
82 #define key_pending(x) (!is_idle())
84 #define EDITOR_MINIMUM_TERMINAL_WIDTH 30
87 /*** file scope type declarations ****************************************************************/
89 struct line_s
91 unsigned int ch;
92 unsigned int style;
95 /*** file scope variables ************************************************************************/
97 /*** file scope functions ************************************************************************/
98 /* --------------------------------------------------------------------------------------------- */
100 static inline void
101 status_string (WEdit * edit, char *s, int w)
103 char byte_str[16];
104 unsigned char cur_byte = 0;
105 unsigned int cur_utf = 0;
106 int cw = 1;
109 * If we are at the end of file, print <EOF>,
110 * otherwise print the current character as is (if printable),
111 * as decimal and as hex.
113 if (edit->curs1 < edit->last_byte)
115 if (!edit->utf8)
117 cur_byte = edit_get_byte (edit, edit->curs1);
119 g_snprintf (byte_str, sizeof (byte_str), "%4d 0x%03X",
120 (int) cur_byte, (unsigned) cur_byte);
122 else
124 cur_utf = edit_get_utf (edit, edit->curs1, &cw);
125 if (cw > 0)
127 g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
128 (unsigned) cur_utf, (unsigned) cur_utf);
130 else
132 cur_utf = edit_get_byte (edit, edit->curs1);
133 g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
134 (int) cur_utf, (unsigned) cur_utf);
139 else
141 strcpy (byte_str, "<EOF> ");
144 /* The field lengths just prevent the status line from shortening too much */
145 if (simple_statusbar)
146 g_snprintf (s, w,
147 "%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s",
148 edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
149 edit->modified ? 'M' : '-',
150 edit->macro_i < 0 ? '-' : 'R',
151 edit->overwrite == 0 ? '-' : 'O',
152 edit->curs_col + edit->over_col,
153 edit->curs_line + 1,
154 edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
155 #ifdef HAVE_CHARSET
156 source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
157 #else
159 #endif
161 else
162 g_snprintf (s, w,
163 "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s %s",
164 edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
165 edit->modified ? 'M' : '-',
166 edit->macro_i < 0 ? '-' : 'R',
167 edit->overwrite == 0 ? '-' : 'O',
168 edit->curs_col + edit->over_col,
169 edit->start_line + 1,
170 edit->curs_row,
171 edit->curs_line + 1,
172 edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
173 #ifdef HAVE_CHARSET
174 source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
175 #else
177 #endif
181 /* --------------------------------------------------------------------------------------------- */
183 static inline void
184 printwstr (const char *s, int len)
186 if (len > 0)
187 tty_printf ("%-*.*s", len, len, s);
190 /* --------------------------------------------------------------------------------------------- */
192 static inline void
193 print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
194 long end_col, struct line_s line[], char *status, int bookmarked)
196 struct line_s *p;
198 int x = start_col_real;
199 int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
200 int y = row + EDIT_TEXT_VERTICAL_OFFSET;
201 int cols_to_skip = abs (x);
202 int i;
204 tty_setcolor (EDITOR_NORMAL_COLOR);
205 if (bookmarked != 0)
206 tty_setcolor (bookmarked);
208 if (!show_right_margin)
210 int len;
212 len = end_col + 1 - start_col;
213 if (len > 0)
214 tty_draw_hline (edit->widget.y + y, edit->widget.x + x1, ' ', len);
216 else if (edit->start_col < option_word_wrap_line_length)
218 int len;
220 len = option_word_wrap_line_length - edit->start_col;
221 if (len > 0)
223 tty_draw_hline (edit->widget.y + y, edit->widget.x + x1, ' ', len);
225 len = end_col + 1 - start_col;
226 if (len > 0)
228 tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
229 tty_draw_hline (edit->widget.y + y,
230 edit->widget.x + x1 + option_word_wrap_line_length +
231 edit->start_col, ' ', len);
236 if (option_line_state)
238 for (i = 0; i < LINE_STATE_WIDTH; i++)
239 if (status[i] == '\0')
240 status[i] = ' ';
242 tty_setcolor (LINE_STATE_COLOR);
243 edit_move (x1 + FONT_OFFSET_X - option_line_state_width, y + FONT_OFFSET_Y);
244 tty_print_string (status);
247 edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y);
248 p = line;
249 i = 1;
250 while (p->ch)
252 int style;
253 unsigned int textchar;
254 int color;
256 if (cols_to_skip)
258 p++;
259 cols_to_skip--;
260 continue;
263 style = p->style & 0xFF00;
264 textchar = p->ch;
265 color = p->style >> 16;
267 if (style & MOD_ABNORMAL)
269 /* Non-printable - use black background */
270 color = 0;
273 if (style & MOD_WHITESPACE)
275 if (style & MOD_MARKED)
277 textchar = ' ';
278 tty_setcolor (EDITOR_MARKED_COLOR);
280 else
282 #if 0
283 if (color != EDITOR_NORMAL_COLOR)
285 textchar = ' ';
286 tty_lowlevel_setcolor (color);
288 else
289 #endif
290 tty_setcolor (EDITOR_WHITESPACE_COLOR);
293 else
295 if (style & MOD_BOLD)
297 tty_setcolor (EDITOR_BOLD_COLOR);
299 else if (style & MOD_MARKED)
301 tty_setcolor (EDITOR_MARKED_COLOR);
303 else
305 tty_lowlevel_setcolor (color);
308 if (show_right_margin)
310 if (i > option_word_wrap_line_length + edit->start_col)
311 tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
312 i++;
314 tty_print_anychar (textchar);
315 p++;
319 /* --------------------------------------------------------------------------------------------- */
320 /** b is a pointer to the beginning of the line */
322 static void
323 edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_col)
325 struct line_s line[MAX_LINE_LEN];
326 struct line_s *p = line;
328 long m1 = 0, m2 = 0, q, c1, c2;
329 int col, start_col_real;
330 unsigned int c;
331 int color;
332 int abn_style;
333 int i;
334 int utf8lag = 0;
335 unsigned int cur_line = 0;
336 int book_mark = 0;
337 char line_stat[LINE_STATE_WIDTH + 1];
339 if (row > edit->widget.lines - EDIT_TEXT_VERTICAL_OFFSET)
340 return;
342 if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_COLOR))
343 book_mark = BOOK_MARK_COLOR;
344 else if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_FOUND_COLOR))
345 book_mark = BOOK_MARK_FOUND_COLOR;
347 if (book_mark)
348 abn_style = book_mark << 16;
349 else
350 abn_style = MOD_ABNORMAL;
352 end_col -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
354 edit_get_syntax_color (edit, b - 1, &color);
355 q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
356 start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
357 if (option_line_state)
359 cur_line = edit->start_line + row;
360 if (cur_line <= (unsigned int) edit->total_lines)
362 g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
364 else
366 memset (line_stat, ' ', LINE_STATE_WIDTH);
367 line_stat[LINE_STATE_WIDTH] = '\0';
369 if (book_mark_query_color (edit, cur_line, BOOK_MARK_COLOR))
371 g_snprintf (line_stat, 2, "*");
375 if (col + 16 > -edit->start_col)
377 eval_marks (edit, &m1, &m2);
379 if (row <= edit->total_lines - edit->start_line)
381 long tws = 0;
382 if (tty_use_colors () && visible_tws)
384 tws = edit_eol (edit, b);
385 while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' ' || c == '\t'))
386 tws--;
389 while (col <= end_col - edit->start_col)
391 int cw = 1;
393 p->ch = 0;
394 p->style = 0;
395 if (q == edit->curs1)
396 p->style |= MOD_CURSOR;
397 if (q >= m1 && q < m2)
399 if (edit->column_highlight)
401 int x;
402 x = edit_move_forward3 (edit, b, 0, q);
403 c1 = min (edit->column1, edit->column2);
404 c2 = max (edit->column1, edit->column2);
405 if (x >= c1 && x < c2)
406 p->style |= MOD_MARKED;
408 else
409 p->style |= MOD_MARKED;
411 if (q == edit->bracket)
412 p->style |= MOD_BOLD;
413 if (q >= edit->found_start && q < edit->found_start + edit->found_len)
414 p->style |= MOD_BOLD;
416 if (!edit->utf8)
418 c = edit_get_byte (edit, q);
420 else
422 c = edit_get_utf (edit, q, &cw);
424 /* we don't use bg for mc - fg contains both */
425 if (book_mark)
427 p->style |= book_mark << 16;
429 else
431 edit_get_syntax_color (edit, q, &color);
432 p->style |= color << 16;
434 switch (c)
436 case '\n':
437 col = (end_col + utf8lag) - edit->start_col + 1; /* quit */
438 break;
439 case '\t':
440 i = TAB_SIZE - ((int) col % TAB_SIZE);
441 col += i;
442 if (tty_use_colors () &&
443 ((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws))
445 if (p->style & MOD_MARKED)
446 c = p->style;
447 else if (book_mark)
448 c |= book_mark << 16;
449 else
450 c = p->style | MOD_WHITESPACE;
451 if (i > 2)
453 p->ch = '<';
454 p->style = c;
455 p++;
456 while (--i > 1)
458 p->ch = '-';
459 p->style = c;
460 p++;
462 p->ch = '>';
463 p->style = c;
464 p++;
466 else if (i > 1)
468 p->ch = '<';
469 p->style = c;
470 p++;
471 p->ch = '>';
472 p->style = c;
473 p++;
475 else
477 p->ch = '>';
478 p->style = c;
479 p++;
482 else if (tty_use_colors () && visible_tws && q >= tws && enable_show_tabs_tws)
484 p->ch = '.';
485 p->style |= MOD_WHITESPACE;
486 c = p->style & ~MOD_CURSOR;
487 p++;
488 while (--i)
490 p->ch = ' ';
491 p->style = c;
492 p++;
495 else
497 p->ch |= ' ';
498 c = p->style & ~MOD_CURSOR;
499 p++;
500 while (--i)
502 p->ch = ' ';
503 p->style = c;
504 p++;
507 break;
508 case ' ':
509 if (tty_use_colors () && visible_tws && q >= tws && enable_show_tabs_tws)
511 p->ch = '.';
512 p->style |= MOD_WHITESPACE;
513 p++;
514 col++;
515 break;
517 /* fallthrough */
518 default:
519 #ifdef HAVE_CHARSET
520 if (utf8_display)
522 if (!edit->utf8)
524 c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
527 else if (edit->utf8)
528 c = convert_from_utf_to_current_c (c, edit->converter);
529 else
530 #endif
531 c = convert_to_display_c (c);
533 /* Caret notation for control characters */
534 if (c < 32)
536 p->ch = '^';
537 p->style = abn_style;
538 p++;
539 p->ch = c + 0x40;
540 p->style = abn_style;
541 p++;
542 col += 2;
543 break;
545 if (c == 127)
547 p->ch = '^';
548 p->style = abn_style;
549 p++;
550 p->ch = '?';
551 p->style = abn_style;
552 p++;
553 col += 2;
554 break;
556 if (!edit->utf8)
558 if ((utf8_display && g_unichar_isprint (c)) ||
559 (!utf8_display && is_printable (c)))
561 p->ch = c;
562 p++;
564 else
566 p->ch = '.';
567 p->style = abn_style;
568 p++;
571 else
573 if (g_unichar_isprint (c))
575 p->ch = c;
576 p++;
578 else
580 p->ch = '.';
581 p->style = abn_style;
582 p++;
585 col++;
586 break;
587 } /* case */
589 q++;
590 if (cw > 1)
592 q += cw - 1;
597 else
599 start_col_real = start_col = 0;
602 p->ch = '\0';
604 print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat, book_mark);
607 /* --------------------------------------------------------------------------------------------- */
609 static inline void
610 edit_draw_this_char (WEdit * edit, long curs, long row)
612 int b = edit_bol (edit, curs);
613 edit_draw_this_line (edit, b, row, 0, edit->widget.cols - 1);
616 /* --------------------------------------------------------------------------------------------- */
617 /** cursor must be in screen for other than REDRAW_PAGE passed in force */
619 static inline void
620 render_edit_text (WEdit * edit, long start_row, long start_column, long end_row, long end_column)
622 long row = 0, curs_row;
623 static long prev_curs_row = 0;
624 static long prev_curs = 0;
626 int force = edit->force;
627 long b;
629 edit->widget.lines = max (edit->widget.lines, 1);
630 edit->widget.cols = max (edit->widget.cols, 1);
633 * If the position of the page has not moved then we can draw the cursor
634 * character only. This will prevent line flicker when using arrow keys.
636 if ((!(force & REDRAW_CHAR_ONLY)) || (force & REDRAW_PAGE))
638 if (!(force & REDRAW_IN_BOUNDS))
639 { /* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */
640 start_row = 0;
641 end_row = edit->widget.lines - 1;
642 start_column = 0;
643 end_column = edit->widget.cols - 1;
645 if (force & REDRAW_PAGE)
647 row = start_row;
648 b = edit_move_forward (edit, edit->start_display, start_row, 0);
649 while (row <= end_row)
651 if (key_pending (edit))
652 return;
653 edit_draw_this_line (edit, b, row, start_column, end_column);
654 b = edit_move_forward (edit, b, 1, 0);
655 row++;
658 else
660 curs_row = edit->curs_row;
662 if (force & REDRAW_BEFORE_CURSOR)
664 if (start_row < curs_row)
666 long upto = curs_row - 1 <= end_row ? curs_row - 1 : end_row;
667 row = start_row;
668 b = edit->start_display;
669 while (row <= upto)
671 if (key_pending (edit))
672 return;
673 edit_draw_this_line (edit, b, row, start_column, end_column);
674 b = edit_move_forward (edit, b, 1, 0);
678 /* if (force & REDRAW_LINE) ---> default */
679 b = edit_bol (edit, edit->curs1);
680 if (curs_row >= start_row && curs_row <= end_row)
682 if (key_pending (edit))
683 return;
684 edit_draw_this_line (edit, b, curs_row, start_column, end_column);
686 if (force & REDRAW_AFTER_CURSOR)
688 if (end_row > curs_row)
690 row = curs_row + 1 < start_row ? start_row : curs_row + 1;
691 b = edit_move_forward (edit, b, 1, 0);
692 while (row <= end_row)
694 if (key_pending (edit))
695 return;
696 edit_draw_this_line (edit, b, row, start_column, end_column);
697 b = edit_move_forward (edit, b, 1, 0);
698 row++;
702 if (force & REDRAW_LINE_ABOVE && curs_row >= 1)
704 row = curs_row - 1;
705 b = edit_move_backward (edit, edit_bol (edit, edit->curs1), 1);
706 if (row >= start_row && row <= end_row)
708 if (key_pending (edit))
709 return;
710 edit_draw_this_line (edit, b, row, start_column, end_column);
713 if (force & REDRAW_LINE_BELOW && row < edit->widget.lines - 1)
715 row = curs_row + 1;
716 b = edit_bol (edit, edit->curs1);
717 b = edit_move_forward (edit, b, 1, 0);
718 if (row >= start_row && row <= end_row)
720 if (key_pending (edit))
721 return;
722 edit_draw_this_line (edit, b, row, start_column, end_column);
727 else
729 if (prev_curs_row < edit->curs_row)
730 { /* with the new text highlighting, we must draw from the top down */
731 edit_draw_this_char (edit, prev_curs, prev_curs_row);
732 edit_draw_this_char (edit, edit->curs1, edit->curs_row);
734 else
736 edit_draw_this_char (edit, edit->curs1, edit->curs_row);
737 edit_draw_this_char (edit, prev_curs, prev_curs_row);
741 edit->force = 0;
743 prev_curs_row = edit->curs_row;
744 prev_curs = edit->curs1;
747 /* --------------------------------------------------------------------------------------------- */
749 static inline void
750 edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end)
752 if (page) /* if it was an expose event, 'page' would be set */
753 edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS;
755 if (edit->force & REDRAW_COMPLETELY)
756 buttonbar_redraw (find_buttonbar (edit->widget.owner));
757 render_edit_text (edit, row_start, col_start, row_end, col_end);
759 * edit->force != 0 means a key was pending and the redraw
760 * was halted, so next time we must redraw everything in case stuff
761 * was left undrawn from a previous key press.
763 if (edit->force)
764 edit->force |= REDRAW_PAGE;
767 /* --------------------------------------------------------------------------------------------- */
768 /*** public functions ****************************************************************************/
769 /* --------------------------------------------------------------------------------------------- */
771 /** Draw the status line at the top of the screen. The size of the filename
772 * field varies depending on the width of the screen and the length of
773 * the filename. */
774 void
775 edit_status (WEdit * edit)
777 const int w = edit->widget.owner->cols;
778 const size_t status_size = w + 1;
779 char *const status = g_malloc (status_size);
780 int status_len;
781 const char *fname = "";
782 int fname_len;
783 const int gap = 3; /* between the filename and the status */
784 const int right_gap = 5; /* at the right end of the screen */
785 const int preferred_fname_len = 16;
787 status_string (edit, status, status_size);
788 status_len = (int) str_term_width1 (status);
790 if (edit->filename)
791 fname = edit->filename;
792 fname_len = str_term_width1 (fname);
793 if (fname_len < preferred_fname_len)
794 fname_len = preferred_fname_len;
796 if (fname_len + gap + status_len + right_gap >= w)
798 if (preferred_fname_len + gap + status_len + right_gap >= w)
799 fname_len = preferred_fname_len;
800 else
801 fname_len = w - (gap + status_len + right_gap);
802 fname = str_trunc (fname, fname_len);
805 dlg_move (edit->widget.owner, 0, 0);
806 tty_setcolor (STATUSBAR_COLOR);
807 printwstr (fname, fname_len + gap);
808 printwstr (status, w - (fname_len + gap));
810 if (simple_statusbar && w > EDITOR_MINIMUM_TERMINAL_WIDTH)
812 size_t percent = 100;
814 if (edit->total_lines + 1 != 0)
815 percent = (edit->curs_line + 1) * 100 / (edit->total_lines + 1);
816 dlg_move (edit->widget.owner, 0, w - 5);
817 tty_printf (" %3d%%", percent);
820 g_free (status);
823 /* --------------------------------------------------------------------------------------------- */
824 /** this scrolls the text so that cursor is on the screen */
825 void
826 edit_scroll_screen_over_cursor (WEdit * edit)
828 int p;
829 int outby;
830 int b_extreme, t_extreme, l_extreme, r_extreme;
832 if (edit->widget.lines <= 0 || edit->widget.cols <= 0)
833 return;
835 edit->widget.cols -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
836 edit->widget.lines -= EDIT_TEXT_VERTICAL_OFFSET - 1;
838 r_extreme = EDIT_RIGHT_EXTREME;
839 l_extreme = EDIT_LEFT_EXTREME;
840 b_extreme = EDIT_BOTTOM_EXTREME;
841 t_extreme = EDIT_TOP_EXTREME;
842 if (edit->found_len)
844 b_extreme = max (edit->widget.lines / 4, b_extreme);
845 t_extreme = max (edit->widget.lines / 4, t_extreme);
847 if (b_extreme + t_extreme + 1 > edit->widget.lines)
849 int n;
851 n = b_extreme + t_extreme;
852 if (n == 0)
853 n = 1;
854 b_extreme = (b_extreme * (edit->widget.lines - 1)) / n;
855 t_extreme = (t_extreme * (edit->widget.lines - 1)) / n;
857 if (l_extreme + r_extreme + 1 > edit->widget.cols)
859 int n;
861 n = l_extreme + t_extreme;
862 if (n == 0)
863 n = 1;
864 l_extreme = (l_extreme * (edit->widget.cols - 1)) / n;
865 r_extreme = (r_extreme * (edit->widget.cols - 1)) / n;
867 p = edit_get_col (edit) + edit->over_col;
868 edit_update_curs_row (edit);
869 outby = p + edit->start_col - edit->widget.cols + 1 + (r_extreme + edit->found_len);
870 if (outby > 0)
871 edit_scroll_right (edit, outby);
872 outby = l_extreme - p - edit->start_col;
873 if (outby > 0)
874 edit_scroll_left (edit, outby);
875 p = edit->curs_row;
876 outby = p - edit->widget.lines + 1 + b_extreme;
877 if (outby > 0)
878 edit_scroll_downward (edit, outby);
879 outby = t_extreme - p;
880 if (outby > 0)
881 edit_scroll_upward (edit, outby);
882 edit_update_curs_row (edit);
884 edit->widget.lines += EDIT_TEXT_VERTICAL_OFFSET - 1;
885 edit->widget.cols += EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
888 /* --------------------------------------------------------------------------------------------- */
890 void
891 edit_render_keypress (WEdit * edit)
893 edit_render (edit, 0, 0, 0, 0, 0);
896 /* --------------------------------------------------------------------------------------------- */