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/main.h"
42 #include "../src/charsets.h"
43 #include "../src/tty/tty.h"
44 #include "../src/skin/skin.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 gboolean read_res
= TRUE
;
73 struct hexedit_change_node
*curr
= view
->change_list
;
75 mcview_display_clean (view
);
76 mcview_display_ruler (view
);
78 /* Find the first displayable changed byte */
79 from
= view
->dpy_start
;
80 while (curr
&& (curr
->offset
< from
)) {
84 tty_setcolor (NORMAL_COLOR
);
85 for (row
= 0, col
= 0; row
< height
;) {
88 c
= mcview_get_utf (view
, from
, &cw
, &read_res
);
94 if (! mcview_get_byte (view
, from
, &c
))
101 if (c
!= '\n' && prev_ch
== '\r') {
104 tty_print_anychar ('\n');
111 if ((c
== '\n') || (col
>= width
&& view
->text_wrap_mode
)) {
114 if (c
== '\n' || row
>= height
)
120 mcview_offset_to_coord (view
, &line
, &column
, from
);
121 col
+= (8 - column
% 8);
122 if (view
->text_wrap_mode
&& col
>= width
&& width
!= 0) {
129 if (view
->search_start
<= from
&& from
< view
->search_end
) {
130 tty_setcolor (SELECTED_COLOR
);
133 if (col
>= view
->dpy_text_column
&& col
- view
->dpy_text_column
< width
) {
134 widget_move (view
, top
+ row
, left
+ (col
- view
->dpy_text_column
));
138 c
= convert_from_8bit_to_utf_c (c
, view
->converter
);
140 if (!g_unichar_isprint (c
))
144 c
= convert_from_utf_to_current_c (c
, view
->converter
);
147 c
= convert_to_display_c (c
);
152 tty_print_anychar (c
);
155 tty_setcolor (NORMAL_COLOR
);
157 view
->dpy_end
= from
;
160 /* --------------------------------------------------------------------------------------------- */