summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/TEHistory.cpp
authorllornkcor <llornkcor>2002-10-31 14:49:24 (UTC)
committer llornkcor <llornkcor>2002-10-31 14:49:24 (UTC)
commitc3a6f53669140cf9e3c953772c610cd91d69ab78 (patch) (unidiff)
treeab8579e66582aedc01da2aea4272e754902e9287 /core/apps/embeddedkonsole/TEHistory.cpp
parent7d8a563125b981718ae963ba6308e3506e870045 (diff)
downloadopie-c3a6f53669140cf9e3c953772c610cd91d69ab78.zip
opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.gz
opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.bz2
no wrap mode taken from console, gui needs work
Diffstat (limited to 'core/apps/embeddedkonsole/TEHistory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEHistory.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp
index 317ce57..db9d10c 100644
--- a/core/apps/embeddedkonsole/TEHistory.cpp
+++ b/core/apps/embeddedkonsole/TEHistory.cpp
@@ -6,17 +6,17 @@
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19#include "TEHistory.h" 19#include "TEHistory.h"
20#include <stdlib.h> 20#include <stdlib.h>
21#include <assert.h> 21#include <assert.h>
22#include <stdio.h> 22#include <stdio.h>
@@ -114,24 +114,30 @@ bool HistoryBuffer::hasScroll()
114 return ion >= 0; 114 return ion >= 0;
115} 115}
116 116
117void HistoryBuffer::add(const unsigned char* bytes, int len) 117void HistoryBuffer::add(const unsigned char* bytes, int len)
118{ int rc; 118{ int rc;
119 assert(hasScroll()); 119 assert(hasScroll());
120 rc = lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; } 120 rc = lseek( ion, length, SEEK_SET);
121 rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; } 121 if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; }
122 rc = write( ion, bytes, len);
123 if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; }
122 length += rc; 124 length += rc;
123} 125}
124 126
125void HistoryBuffer::get(unsigned char* bytes, int len, int loc) 127void HistoryBuffer::get(unsigned char* bytes, int len, int loc) {
126{ int rc; 128 int rc;
127 assert(hasScroll()); 129 assert(hasScroll());
130// qDebug("history get len %d, loc %d, length %d", len, loc, length);
128 if (loc < 0 || len < 0 || loc + len > length) 131 if (loc < 0 || len < 0 || loc + len > length)
129 fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc); 132 fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc);
130 rc = lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; } 133
131 rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; } 134 rc = lseek( ion, loc, SEEK_SET);
135 if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; }
136 rc = read( ion, bytes, len);
137 if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; }
132} 138}
133 139
134int HistoryBuffer::len() 140int HistoryBuffer::len()
135{ 141{
136 return length; 142 return length;
137} 143}
@@ -192,13 +198,14 @@ int HistoryScroll::startOfLine(int lineno)
192 return cells.len(); 198 return cells.len();
193} 199}
194 200
195void HistoryScroll::getCells(int lineno, int colno, int count, ca res[]) 201void HistoryScroll::getCells(int lineno, int colno, int count, ca res[])
196{ 202{
197 assert(hasScroll()); 203 assert(hasScroll());
198 cells.get((unsigned char*)res,count*sizeof(ca),startOfLine(lineno)+colno*sizeof(ca)); 204//get(unsigned char* bytes, int len, int loc)
205 cells.get( (unsigned char*)res, count * sizeof(ca), startOfLine( lineno) + colno * sizeof(ca) );
199} 206}
200 207
201void HistoryScroll::addCells(ca text[], int count) 208void HistoryScroll::addCells(ca text[], int count)
202{ 209{
203 if (!hasScroll()) return; 210 if (!hasScroll()) return;
204 cells.add((unsigned char*)text,count*sizeof(ca)); 211 cells.add((unsigned char*)text,count*sizeof(ca));