ReactOS 0.4.15-dev-8102-g108db8f
TScroller Class Reference

#include <tscroll.h>

Collaboration diagram for TScroller:

Public Member Functions

void init (stripfunc *s)
 
void update (const char *pszBegin, const char *pszEnd)
 
void ScrollBack ()
 
 TScroller (TMouse &M, int size=20000)
 
 ~TScroller ()
 

Private Attributes

charpcScrollData
 
long iScrollSize
 
long iScrollEnd
 
int iPastEnd
 
int iDisplay
 
stripfuncstrip
 
TMouseMouse
 

Detailed Description

Definition at line 8 of file tscroll.h.

Constructor & Destructor Documentation

◆ TScroller()

TScroller::TScroller ( TMouse M,
int  size = 20000 
)

Definition at line 52 of file tscroll.cpp.

52 : Mouse(M) {
54 pcScrollData = new char[iScrollSize];
55 iScrollEnd = 0;
56 iPastEnd = 0;
58
59 if(stricmp(ini.get_scroll_mode(), "hex") == 0) iDisplay = HEX;
60 else if(stricmp(ini.get_scroll_mode(), "dump") == 0) iDisplay = DUMP;
61 else if(stricmp(ini.get_scroll_mode(), "dumpb") == 0) iDisplay = DUMPB;
62 else if(stricmp(ini.get_scroll_mode(), "text") == 0) iDisplay = TEXTB;
63 else iDisplay = DUMP;
64
66}
#define DUMP(Command, Pad)
const char * get_scroll_mode() const
Definition: tnconfig.h:89
TMouse & Mouse
Definition: tscroll.h:16
stripfunc * strip
Definition: tscroll.h:15
long iScrollEnd
Definition: tscroll.h:12
int iPastEnd
Definition: tscroll.h:13
char * pcScrollData
Definition: tscroll.h:10
long iScrollSize
Definition: tscroll.h:11
int iDisplay
Definition: tscroll.h:14
#define M(row, col)
#define stricmp(_String1, _String2)
Definition: compat.h:24
GLsizeiptr size
Definition: glext.h:5919
#define memset(x, y, z)
Definition: compat.h:39
TConfig ini
Definition: tnconfig.cpp:45
int DummyStripBuffer(char *start, char *end, int width)
Definition: tscroll.cpp:50
@ TEXTB
Definition: tscroll.cpp:47
@ DUMPB
Definition: tscroll.cpp:46
#define HEX(y)
Definition: x86common.h:3

◆ ~TScroller()

TScroller::~TScroller ( )

Definition at line 68 of file tscroll.cpp.

68 {
69 delete[] pcScrollData;
70}

Member Function Documentation

◆ init()

void TScroller::init ( stripfunc s)

Definition at line 72 of file tscroll.cpp.

72 {
73 strip = s;
74}
GLdouble s
Definition: gl.h:2039

Referenced by TANSIParser::TANSIParser().

◆ ScrollBack()

void TScroller::ScrollBack ( )

Definition at line 163 of file tscroll.cpp.

163 {
164 char p;
165 int r,c;
166
167 // define colors (Paul Brannan 7/5/98)
168 int normal = (ini.get_scroll_bg() << 4) | ini.get_scroll_fg();
169 // int inverse = (ini.get_scroll_fg() << 4) | ini.get_scroll_bg();
170 int status = (ini.get_status_bg() << 4) | ini.get_status_fg();
171
172 CHAR_INFO* chiBuffer;
173 chiBuffer = newBuffer();
174 saveScreen(chiBuffer);
175
179
180 // Update iScrollBegin -- necessary in case the buffer isn't full yet
181 long iScrollBegin, iScrollLast;
182 if(iPastEnd == 0) {
183 iScrollBegin = 0;
184 iScrollLast = iScrollEnd - 1;
185 } else {
186 iScrollBegin = iScrollEnd;
187 iScrollLast = iScrollSize - 1;
188 }
189
190 // Create buffer with ANSI codes stripped
191 // Fixed this to work properly with a circular buffer (PB 12/4/98)
192 char *stripped = new char[iScrollSize];
193 memcpy(stripped, pcScrollData + iScrollBegin, iScrollSize -
194 iScrollBegin);
195 if(iScrollBegin != 0) memcpy(stripped + (iScrollSize - iScrollBegin),
196 pcScrollData, iScrollBegin - 1);
197 int strippedlines = (*strip)(stripped, stripped + iScrollLast,
198 CON_COLS);
199
200 // Calculate the last line of the scroll buffer (Paul Brannan 12/4/98)
201 int maxlines = setmaxlines(iDisplay, iScrollLast + 1, strippedlines,
202 CON_COLS);
203
204 // init scroll position
205 int current = maxlines - CON_HEIGHT + 1;
206 if(current < 0) current = 0;
207
208 // paint border and info
209 // paint last two lines black on white
210 char * szStatusLine;
211 szStatusLine = new char[CON_WIDTH+2];
212 setstatusline(szStatusLine, CON_COLS, iDisplay);
215
216 // loop while not done
217 BOOL done = FALSE;
218 while (!done){
219 switch (iDisplay){
220 case HEX:
221 memset(szStatusLine, ' ', CON_COLS);
222 szStatusLine[8] = ':';
223 szStatusLine[34] = '-';
224 for (r = 0; r < CON_HEIGHT; r++) {
225 hexify((r + current) * 16, &szStatusLine[2], 6);
226 for (c = 0; c < 16; c++){
227 if (c+(16*(r+current)) >= iScrollLast)
228 p = 0;
229 else
230 p = pcScrollData[(c+16*(r+current) + iScrollBegin) %
232 hexify((char)p, &szStatusLine[11 + 3*c], 2);
233 if (!iscntrl(p)) {
234 szStatusLine[60 + c] = (char)p;
235 } else {
236 szStatusLine[60 + c] = '.';
237 }
238 }
239 for(int j = 0; j < 16; j++) {
240 }
241 szStatusLine[CON_COLS] = '\0';
244 }
245 break;
246 case DUMP:
247 for (r = 0; r < CON_HEIGHT; r++) {
248 for (c = 0; c <= CON_WIDTH; c++) {
249 if (c+((CON_COLS)*(r+current)) >= iScrollLast) p = ' ';
250 else p = pcScrollData[(c+((CON_COLS)*(r+current))
251 + iScrollBegin) % iScrollSize];
252 if (!iscntrl(p))
253 szStatusLine[c] = p;
254 else
255 szStatusLine[c] = '.';
256 }
257 szStatusLine[c] = '\0';
260 }
261 break;
262 case DUMPB:
263 for (r = 0; r < CON_HEIGHT; r++) {
264 for (c = 0; c <= CON_WIDTH; c++) {
265 if (c+((CON_COLS)*(r+current)) >= iScrollLast) p = ' ';
266 else p = pcScrollData[ (c+((CON_COLS)*(r+current))
267 + iScrollBegin) % iScrollSize];
268 if (p != 0)
269 szStatusLine[c] = p;
270 else
271 szStatusLine[c] = ' ';
272 }
273 szStatusLine[c] = '\0';
276 }
277 break;
278 case TEXTB: {
279 int ch, lines, x;
280 // Find the starting position
281 for(ch = 0, lines = 0, x = 1; ch < iScrollSize &&
282 lines < current; ch++, x++) {
283
284 if(stripped[ch] == '\n') lines++;
285 if(stripped[ch] == '\r') x = 1;
286 }
287
288 for (r = 0; r < CON_HEIGHT; r++) {
289 memset(szStatusLine, ' ', CON_COLS);
290 for(c = 0; c <= CON_WIDTH; c++) {
291 done = FALSE;
292 if (ch >= iScrollSize) p = ' ';
293 else p = stripped[ch];
294 switch(p) {
295 case 10: done = TRUE; break;
296 case 13: c = 0; break;
297 default: szStatusLine[c] = p;
298 }
299 ch++;
300 if(done) break;
301 }
302 szStatusLine[CON_COLS] = '\0';
305 }
306 }
307 break;
308 }
309
310 setstatusline(szStatusLine, CON_COLS, iDisplay);
313
314 // paint scroll back data
315 // get key input
316 switch(scrollkeys()){
317 case VK_ESCAPE:
318 done = TRUE;
319 break;
320 case VK_PRIOR:
321 if ( current > CON_HEIGHT)
323 else
324 current = 0;
325 break;
326 case VK_NEXT:
327 if ( current < maxlines - 2*CON_HEIGHT + 2)
329 else
330 current = maxlines - CON_HEIGHT + 1;
331 break;
332 case VK_DOWN:
333 if (current <= maxlines - CON_HEIGHT) current++;
334 break;
335 case VK_UP:
336 if ( current > 0) current--;
337 break;
338 case VK_TAB:
339 iDisplay = (iDisplay+1)%4;
340 maxlines = setmaxlines(iDisplay, iScrollLast + 1, strippedlines,
341 CON_COLS);
342 if(current > maxlines) current = maxlines - 1;
343 if(current < 0) current = 0;
344 break;
345 case VK_END:
346 current = maxlines - CON_HEIGHT + 1;
347 if(current < 0) current = 0;
348 break;
349 case VK_HOME:
350 current = 0;
351 break;
352 case SC_MOUSE:
354 break;
355 }
356 }
357
358 // Clean up
359 restoreScreen(chiBuffer);
360 delete[] szStatusLine;
361 delete[] chiBuffer;
362 delete[] stripped;
363}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
int get_status_bg() const
Definition: tnconfig.h:75
int get_status_fg() const
Definition: tnconfig.h:76
int get_scroll_fg() const
Definition: tnconfig.h:74
int get_scroll_bg() const
Definition: tnconfig.h:73
void scrollMouse()
Definition: tmouse.cpp:207
HANDLE hStdout
Definition: ctm.c:56
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char
Definition: typeof.h:29
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
_Check_return_ _CRTIMP int __cdecl iscntrl(_In_ int _C)
#define c
Definition: ke_i.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct task_struct * current
Definition: linux.c:32
@ normal
Definition: optimize.h:166
Definition: ps.c:97
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
void saveScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:934
void restoreScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:964
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995
#define CON_TOP
Definition: tconsole.h:45
#define CON_LEFT
Definition: tconsole.h:48
#define CON_HEIGHT
Definition: tconsole.h:51
#define CON_COLS
Definition: tconsole.h:54
#define CON_WIDTH
Definition: tconsole.h:52
#define CON_BOTTOM
Definition: tconsole.h:46
WORD scrollkeys()
Definition: tncon.cpp:320
@ SC_MOUSE
Definition: tncon.h:11
eMaj lines
Definition: tritemp.h:206
static int setmaxlines(int iDisplay, int iScrollSize, int strippedlines, int con_width)
Definition: tscroll.cpp:139
static BOOL WriteConsoleOutputCharAndAttribute(HANDLE hConsoleOutput, CHAR *lpWriteBuffer, WORD wAttrib, SHORT sX, SHORT sY)
Definition: tscroll.cpp:97
static void setstatusline(char *szStatusLine, int len, int iDisplay)
Definition: tscroll.cpp:150
static void hexify(int x, char *str, int len)
Definition: tscroll.cpp:130
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define VK_TAB
Definition: winuser.h:2199
#define VK_UP
Definition: winuser.h:2225
#define VK_NEXT
Definition: winuser.h:2221
#define VK_END
Definition: winuser.h:2222
#define VK_HOME
Definition: winuser.h:2223
#define VK_DOWN
Definition: winuser.h:2227
#define VK_PRIOR
Definition: winuser.h:2220
#define VK_ESCAPE
Definition: winuser.h:2214

Referenced by Telnet::Resume().

◆ update()

void TScroller::update ( const char pszBegin,
const char pszEnd 
)

Definition at line 78 of file tscroll.cpp.

78 {
79 if ((iScrollEnd)+(pszTail-pszHead) < iScrollSize) {
80 memcpy(&pcScrollData[iScrollEnd], pszHead, pszTail-pszHead);
81 } else if (pszTail-pszHead > iScrollSize) {
83 iScrollEnd = 0;
84 } else {
87 pszTail-pszHead-(iScrollSize-iScrollEnd));
88 }
89
90 // This could probably be optimized better, but it's probably not worth it
91 int temp = iScrollEnd;
92 iScrollEnd = ((iScrollEnd)+(pszTail-pszHead))%iScrollSize;
93 if(iScrollEnd < temp) iPastEnd = 1;
94}
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by TANSIParser::ParseBuffer().

Member Data Documentation

◆ iDisplay

int TScroller::iDisplay
private

Definition at line 14 of file tscroll.h.

Referenced by ScrollBack(), and TScroller().

◆ iPastEnd

int TScroller::iPastEnd
private

Definition at line 13 of file tscroll.h.

Referenced by ScrollBack(), TScroller(), and update().

◆ iScrollEnd

long TScroller::iScrollEnd
private

Definition at line 12 of file tscroll.h.

Referenced by ScrollBack(), TScroller(), and update().

◆ iScrollSize

long TScroller::iScrollSize
private

Definition at line 11 of file tscroll.h.

Referenced by ScrollBack(), TScroller(), and update().

◆ Mouse

TMouse& TScroller::Mouse
private

Definition at line 16 of file tscroll.h.

Referenced by ScrollBack().

◆ pcScrollData

char* TScroller::pcScrollData
private

Definition at line 10 of file tscroll.h.

Referenced by ScrollBack(), TScroller(), update(), and ~TScroller().

◆ strip

stripfunc* TScroller::strip
private

Definition at line 15 of file tscroll.h.

Referenced by init(), and TScroller().


The documentation for this class was generated from the following files: