1 /*
2 * display.c
3 *
4 * All rights reserved. Copyright (C) 1996 by NARITA Tomio.
5 * $Id: display.c,v 1.4 2003/11/13 03:08:19 nrt Exp $
6 */
7 /*
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.
12 *
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.
17 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include <import.h>
24 #include <screen.h>
25 #include <console.h>
26 #include <encode.h>
27 #include <fetch.h>
28 #include <position.h>
29 #include <begin.h>
30 #include <display.h>
31
32 /*
33 * $B%Z!<%8FbMF$r%(%s%3!<%I$7$F2hLL$K=PNO$9$k(B.
34 *
35 * screen.c $B$G%m!<%I$7$?%Z!<%8FbMF$rI=<($9$k(B.
36 * ($B$?$@$7(B, display.c $B$+$i$bF0E*$K%Z!<%8$r%a%b%j$K%m!<%I$7$F$$$k(B).
37 */
38
39 #define ScreenGetTop( f, seg, blk, off, phy ) \
40 PositionGet( (f)->screen.top, (seg), (blk), (off), (phy) )
41
42 #define ScreenGetBot( f, seg, blk, off, phy ) \
43 PositionGet( (f)->screen.bot, (seg), (blk), (off), (phy) )
44
LineEncode(file_t * f,int blk,int off,int phy)45 private void LineEncode( file_t *f, int blk, int off, int phy )
46 {
47 line_t *line;
48 int head, tail;
49
50 line = &f->page[ blk ].line[ off ];
51 head = LineHead( line, phy );
52 tail = head + LineLength( line, phy );
53
54 encode_length = CODE_SIZE;
55 Encode( line->istr, head, tail,
56 f->outputCodingSystem, FALSE,
57 encode_str, &encode_length );
58 }
59
DisplayFull(file_t * f)60 public void DisplayFull( file_t *f )
61 {
62 int i;
63 int seg, blk, off, phy;
64
65 ConsoleOffCur();
66
67 ScreenGetTop( f, seg, blk, off, phy );
68
69 ConsoleClearScreen();
70
71 for( i = 0 ; i < f->screen.lines ; i++ ){
72 LineEncode( f, blk, off, phy );
73 if( 0 == i || TRUE == carefully_divide || 0 == phy ){
74 ConsoleSetCur( 0, i );
75 }
76 ConsolePrintsStr( encode_str, encode_length );
77 PositionInc( f, seg, blk, off, phy );
78 }
79 for( i = f->screen.lines ; i < f->height ; i++ ){
80 ConsoleSetCur( 0, i );
81 ConsolePrint( '~' );
82 }
83
84 ConsoleOnCur();
85
86 f->dirty = FALSE;
87 }
88
DisplayTop(file_t * f,int arg)89 public void DisplayTop( file_t *f, int arg )
90 {
91 int seg, blk, off, phy;
92 int i;
93
94 if( TRUE == no_scroll || arg > f->height || f->screen.lines < f->height ){
95 DisplayFull( f );
96 return;
97 }
98
99 if( arg == f->height ){
100 if( FALSE == smooth_paging ){
101 DisplayFull( f );
102 return;
103 }
104 ScreenGetBot( f, seg, blk, off, phy );
105 } else {
106 ScreenGetTop( f, seg, blk, off, phy );
107 for( i = 1 ; i < arg ; i++ )
108 PositionInc( f, seg, blk, off, phy );
109 }
110
111 ConsoleOffCur();
112
113 for( i = 0 ; i < arg ; i++ ){
114 LineEncode( f, blk, off, phy );
115 ConsoleSetCur( 0, HEIGHT - 1 );
116 ConsoleClearRight();
117 ConsoleSetCur( 0, 0 );
118 ConsoleScrollDown();
119 ConsolePrintsStr( encode_str, encode_length );
120 PositionDec( f, seg, blk, off, phy );
121 }
122
123 ConsoleOnCur();
124 }
125
DisplayBot(file_t * f,int arg)126 public void DisplayBot( file_t *f, int arg )
127 {
128 int seg, blk, off, phy;
129 int i;
130
131 if( TRUE == no_scroll || arg > f->height || f->screen.lines < f->height ){
132 DisplayFull( f );
133 return;
134 }
135
136 if( arg == f->height ){
137 if( FALSE == smooth_paging ){
138 DisplayFull( f );
139 return;
140 }
141 ScreenGetTop( f, seg, blk, off, phy );
142 } else {
143 ScreenGetBot( f, seg, blk, off, phy );
144 for( i = 1 ; i < arg ; i++ )
145 PositionDec( f, seg, blk, off, phy );
146 }
147
148 ConsoleOffCur();
149
150 for( i = 0 ; i < arg ; i++ ){
151 LineEncode( f, blk, off, phy );
152 ConsoleSetCur( 0, 0 );
153 ConsoleScrollUp();
154 ConsoleSetCur( 0, f->height - 1 );
155 ConsoleClearRight();
156 ConsolePrintsStr( encode_str, encode_length );
157 PositionInc( f, seg, blk, off, phy );
158 }
159
160 ConsoleOnCur();
161 }
162