2 Internal file viewer for the Midnight Commander
3 Function for plain view
5 Copyright (C) 1994-2014
6 Free Software Foundation, Inc.
9 Miguel de Icaza, 1994, 1995, 1998
10 Janne Kukonlehto, 1994, 1995
12 Joseph M. Hinkle, 1996
15 Roland Illig <roland.illig@gmx.de>, 2004, 2005
16 Slava Zanko <slavazanko@google.com>, 2009
17 Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2013
18 Ilia Maslakov <il.smind@gmail.com>, 2009
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 3 of the License,
25 or (at your option) any later version.
27 The Midnight Commander is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU 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, see <http://www.gnu.org/licenses/>.
38 #include "lib/global.h"
39 #include "lib/tty/tty.h"
41 #include "lib/util.h" /* is_printable() */
43 #include "lib/charsets.h"
46 #include "src/setup.h" /* option_tab_spacing */
50 /*** global variables ****************************************************************************/
52 /*** file scope macro definitions ****************************************************************/
54 /*** file scope type declarations ****************************************************************/
56 /*** file scope variables ************************************************************************/
58 /*** file scope functions ************************************************************************/
59 /* --------------------------------------------------------------------------------------------- */
61 /* --------------------------------------------------------------------------------------------- */
62 /*** public functions ****************************************************************************/
63 /* --------------------------------------------------------------------------------------------- */
66 mcview_display_text (mcview_t
* view
)
68 const screen_dimen left
= view
->data_area
.left
;
69 const screen_dimen top
= view
->data_area
.top
;
70 const screen_dimen width
= view
->data_area
.width
;
71 const screen_dimen height
= view
->data_area
.height
;
72 screen_dimen row
= 0, col
= 0;
76 gboolean last_row
= TRUE
;
77 struct hexedit_change_node
*curr
= view
->change_list
;
79 mcview_display_clean (view
);
80 mcview_display_ruler (view
);
82 /* Find the first displayable changed byte */
83 from
= view
->dpy_start
;
84 while ((curr
!= NULL
) && (curr
->offset
< from
))
89 tty_setcolor (VIEW_NORMAL_COLOR
);
97 gboolean read_res
= TRUE
;
99 c
= mcview_get_utf (view
, from
, &cw
, &read_res
);
105 if (!mcview_get_byte (view
, from
, &c
))
113 if (c
!= '\n' && prev_ch
== '\r')
119 /* tty_print_anychar ('\n'); */
133 if (col
>= width
&& view
->text_wrap_mode
)
142 col
+= (option_tab_spacing
- col
% option_tab_spacing
);
143 if (view
->text_wrap_mode
&& col
>= width
&& width
!= 0)
151 if (view
->search_start
<= from
&& from
< view
->search_end
)
152 tty_setcolor (SELECTED_COLOR
);
154 if (((off_t
) col
>= view
->dpy_text_column
)
155 && ((off_t
) col
- view
->dpy_text_column
< (off_t
) width
))
157 widget_move (view
, top
+ row
, left
+ ((off_t
) col
- view
->dpy_text_column
));
159 if (mc_global
.utf8_display
)
162 c
= convert_from_8bit_to_utf_c ((unsigned char) c
, view
->converter
);
163 if (!g_unichar_isprint (c
))
167 c
= convert_from_utf_to_current_c (c
, view
->converter
);
172 c
= convert_to_display_c (c
);
174 if (!is_printable (c
))
178 tty_print_anychar (c
);
186 if (g_unichar_iswide (c
))
188 else if (g_unichar_iszerowidth (c
))
194 view
->dpy_end
= from
;
195 if (mcview_show_eof
!= NULL
&& mcview_show_eof
[0] != '\0')
197 if (last_row
&& mcview_get_byte (view
, from
- 1, &c
))
200 while (++row
< height
)
202 widget_move (view
, top
+ row
, left
);
203 tty_print_string (mcview_show_eof
);
208 /* --------------------------------------------------------------------------------------------- */