2 Internal file viewer for the Midnight Commander
3 Function for plain view
5 Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
6 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
8 Written by: 1994, 1995, 1998 Miguel de Icaza
9 1994, 1995 Janne Kukonlehto
14 2004 Roland Illig <roland.illig@gmx.de>
15 2005 Roland Illig <roland.illig@gmx.de>
16 2009 Slava Zanko <slavazanko@google.com>
17 2009 Andrew Borodin <aborodin@vmail.ru>
18 2009 Ilia Maslakov <il.smind@gmail.com>
20 This file is part of the Midnight Commander.
22 The Midnight Commander is free software; you can redistribute it
23 and/or modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2 of the
25 License, or (at your option) any later version.
27 The Midnight Commander is distributed in the hope that it will be
28 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
29 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 General Public License for more details.
32 You should have received a copy of the GNU General Public License
33 along with this program; if not, write to the Free Software
34 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
40 #include "../src/global.h"
41 #include "../src/myslang.h"
42 #include "../src/main.h"
43 #include "../src/color.h"
44 #include "../src/charsets.h"
45 #include "../src/viewer/internal.h"
47 /*** global variables ****************************************************************************/
49 /*** file scope macro definitions ****************************************************************/
51 /*** file scope type declarations ****************************************************************/
53 /*** file scope variables ************************************************************************/
55 /*** file scope functions ************************************************************************/
57 /*** public functions ****************************************************************************/
59 /* --------------------------------------------------------------------------------------------- */
62 mcview_display_text (mcview_t
* view
)
64 const screen_dimen left
= view
->data_area
.left
;
65 const screen_dimen top
= view
->data_area
.top
;
66 const screen_dimen width
= view
->data_area
.width
;
67 const screen_dimen height
= view
->data_area
.height
;
68 screen_dimen row
, col
;
72 struct hexedit_change_node
*curr
= view
->change_list
;
74 mcview_display_clean (view
);
75 mcview_display_ruler (view
);
77 /* Find the first displayable changed byte */
78 from
= view
->dpy_start
;
79 while (curr
&& (curr
->offset
< from
)) {
83 tty_setcolor (NORMAL_COLOR
);
84 for (row
= 0, col
= 0; row
< height
;) {
87 if ((c
= mcview_get_utf (view
, from
, &cw
)) == -1)
92 if ((c
= mcview_get_byte (view
, from
)) == -1)
96 mc_log ("cw=%i\n", cw
);
100 if (view
->text_nroff_mode
&& c
== '\b') {
104 if ((c_next
= mcview_get_byte_indexed (view
, from
, 1)) != -1 && g_ascii_isprint (c_next
)
106 && (c_prev
= mcview_get_byte (view
, from
- 1)) != -1 && g_ascii_isprint (c_prev
)
107 && (c_prev
== c_next
|| c_prev
== '_' || (c_prev
== '+' && c_next
== 'o'))) {
110 /* We're inside an nroff character sequence at the
111 * beginning of the screen -- just skip the
112 * backspace and continue with the next character. */
119 if (c_prev
== '_' && (c_next
!= '_' || mcview_count_backspaces (view
, from
) == 1))
120 tty_setcolor (VIEW_UNDERLINED_COLOR
);
122 tty_setcolor (MARKED_COLOR
);
127 if ((c
== '\n') || (col
>= width
&& view
->text_wrap_mode
)) {
130 if (c
== '\n' || row
>= height
)
135 c
= mcview_get_byte_indexed (view
, from
, 1);
136 if (c
== '\r' || c
== '\n')
145 mcview_offset_to_coord (view
, &line
, &column
, from
);
146 col
+= (8 - column
% 8);
147 if (view
->text_wrap_mode
&& col
>= width
&& width
!= 0) {
154 if (view
->search_start
<= from
&& from
< view
->search_end
) {
155 tty_setcolor (SELECTED_COLOR
);
158 if (col
>= view
->dpy_text_column
&& col
- view
->dpy_text_column
< width
) {
159 widget_move (view
, top
+ row
, left
+ (col
- view
->dpy_text_column
));
163 c
= convert_from_8bit_to_utf_c ((unsigned char) c
, view
->converter
);
167 c
= convert_from_utf_to_current_c (c
, view
->converter
);
170 c
= convert_to_display_c (c
);
175 tty_print_anychar (c
);
178 tty_setcolor (NORMAL_COLOR
);
180 view
->dpy_end
= from
;
183 /* --------------------------------------------------------------------------------------------- */