summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-26 13:41:03 (UTC)
committer josef <josef>2002-10-26 13:41:03 (UTC)
commitffa4d7c4df80207411c27746ae884cbcead4e619 (patch) (unidiff)
tree2e37f5137deebc5f2e36452ca7fed78630cafeb9
parent0d58e14f2bcfa2a1f5c9a197d5bb544571824207 (diff)
downloadopie-ffa4d7c4df80207411c27746ae884cbcead4e619.zip
opie-ffa4d7c4df80207411c27746ae884cbcead4e619.tar.gz
opie-ffa4d7c4df80207411c27746ae884cbcead4e619.tar.bz2
- implement horizontal line wrap
If Line Wrap is enabled for the terminal, the traditional behaviour is kept. Otherwise, a horizontal scroll bar is added and 80 columns are assumed. TODO: - handle modes when there's no vertical scroll bar or it's on the left side - initialize correctly (currently, sometimes moving the scrollbar must be done at first)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp52
-rw-r--r--noncore/apps/opie-console/TEWidget.h6
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp3
-rw-r--r--noncore/apps/opie-console/widget.cpp2
5 files changed, 57 insertions, 9 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index e4415dc..bf9a313 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -85,18 +85,16 @@
85#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 85#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
86 86
87#define loc(X,Y) ((Y)*columns+(X)) 87#define loc(X,Y) ((Y)*columns+(X))
88 88
89//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 89//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
90#define rimX 0 // left/right rim width 90#define rimX 0 // left/right rim width
91#define rimY 0 // top/bottom rim high 91#define rimY 0 // top/bottom rim high
92 92
93#define SCRWIDTH 16 // width of the scrollbar
94
95#define yMouseScroll 1 93#define yMouseScroll 1
96// scroll increment used when dragging selection at top/bottom of window. 94// scroll increment used when dragging selection at top/bottom of window.
97 95
98/* Button XPM */ 96/* Button XPM */
99namespace { 97namespace {
100static char * menu_xpm[] = { 98static char * menu_xpm[] = {
101"12 12 5 1", 99"12 12 5 1",
102 " c None", 100 " c None",
@@ -314,16 +312,20 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
314 this, SLOT(onClearSelection()) ); 312 this, SLOT(onClearSelection()) );
315#endif 313#endif
316 314
317 315
318 scrollbar = new QScrollBar( this ); 316 scrollbar = new QScrollBar( this );
319 scrollbar->setCursor( arrowCursor ); 317 scrollbar->setCursor( arrowCursor );
320 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 318 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
321 319
320 hscrollbar = new QScrollBar( Qt::Horizontal, this );
321 hscrollbar->setCursor( arrowCursor );
322 connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int)));
323
322 m_cornerButton = new QPushButton( this ); 324 m_cornerButton = new QPushButton( this );
323 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 325 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
324 m_cornerButton->setMaximumSize( 14, 14 ); 326 m_cornerButton->setMaximumSize( 14, 14 );
325 m_cornerButton->hide(); 327 m_cornerButton->hide();
326 328
327 Config cfg("Konsole"); 329 Config cfg("Konsole");
328 cfg.setGroup("ScrollBar"); 330 cfg.setGroup("ScrollBar");
329 switch( cfg.readNumEntry("Position",2)){ 331 switch( cfg.readNumEntry("Position",2)){
@@ -347,16 +349,17 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
347 actSel = 0; 349 actSel = 0;
348 image = 0; 350 image = 0;
349 lines = 1; 351 lines = 1;
350 columns = 1; 352 columns = 1;
351 font_w = 1; 353 font_w = 1;
352 font_h = 1; 354 font_h = 1;
353 font_a = 1; 355 font_a = 1;
354 word_selection_mode = FALSE; 356 word_selection_mode = FALSE;
357 vcolumns = 0;
355 358
356 setMouseMarks(TRUE); 359 setMouseMarks(TRUE);
357 setVTFont( QFont("fixed") ); 360 setVTFont( QFont("fixed") );
358 setColorTable(base_color_table); // init color table 361 setColorTable(base_color_table); // init color table
359 362
360 qApp->installEventFilter( this ); //FIXME: see below 363 qApp->installEventFilter( this ); //FIXME: see below
361// KCursor::setAutoHideCursor( this, true ); 364// KCursor::setAutoHideCursor( this, true );
362 365
@@ -625,16 +628,23 @@ void TEWidget::propagateSize()
625/* */ 628/* */
626/* ------------------------------------------------------------------------- */ 629/* ------------------------------------------------------------------------- */
627 630
628void TEWidget::scrollChanged(int) 631void TEWidget::scrollChanged(int)
629{ 632{
630 emit changedHistoryCursor(scrollbar->value()); //expose 633 emit changedHistoryCursor(scrollbar->value()); //expose
631} 634}
632 635
636void TEWidget::hscrollChanged(int loc)
637{
638 hposition = loc;
639 propagateSize();
640 update();
641}
642
633void TEWidget::setScroll(int cursor, int slines) 643void TEWidget::setScroll(int cursor, int slines)
634{ 644{
635 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 645 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
636 scrollbar->setRange(0,slines); 646 scrollbar->setRange(0,slines);
637 scrollbar->setSteps(1,lines); 647 scrollbar->setSteps(1,lines);
638 scrollbar->setValue(cursor); 648 scrollbar->setValue(cursor);
639 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 649 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
640} 650}
@@ -1134,44 +1144,73 @@ void TEWidget::clearImage()
1134} 1144}
1135 1145
1136// Create Image /////////////////////////////////////////////////////// 1146// Create Image ///////////////////////////////////////////////////////
1137 1147
1138void TEWidget::calcGeometry() 1148void TEWidget::calcGeometry()
1139{ 1149{
1140 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1150 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1141 1151
1152 int showhscrollbar = 1;
1153 int hwidth = 0;
1154
1155 if(vcolumns == 0) showhscrollbar = 0;
1156 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1157
1142 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1158 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1143 contentsRect().height()); 1159 contentsRect().height() - hwidth);
1160
1161 if(showhscrollbar == 1)
1162 {
1163 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1164 hscrollbar->setRange(0, 40);
1165
1166 QPoint p = contentsRect().bottomLeft();
1167 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1168 hscrollbar->show();
1169 }
1170 else hscrollbar->hide();
1171
1144 switch(scrollLoc) 1172 switch(scrollLoc)
1145 { 1173 {
1146 case SCRNONE : 1174 case SCRNONE :
1147 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1175 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1176 if(vcolumns) columns = vcolumns;
1148 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1177 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1149 brX = blX; 1178 brX = blX;
1150 scrollbar->hide(); 1179 scrollbar->hide();
1151 break; 1180 break;
1152 case SCRLEFT : 1181 case SCRLEFT :
1153 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1182 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1183 if(vcolumns) columns = vcolumns;
1154 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1184 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1155 blX = brX + scrollbar->width(); 1185 blX = brX + scrollbar->width();
1156 scrollbar->move(contentsRect().topLeft()); 1186 scrollbar->move(contentsRect().topLeft());
1157 scrollbar->show(); 1187 scrollbar->show();
1158 break; 1188 break;
1159 case SCRRIGHT: 1189 case SCRRIGHT:
1160 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1190 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1191 if(vcolumns) columns = vcolumns;
1161 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1192 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1193 if(showhscrollbar)
1194 blX = -hposition * font_w;
1162 brX = blX; 1195 brX = blX;
1163 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1196 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1164 scrollbar->show(); 1197 scrollbar->show();
1165 break; 1198 break;
1166 } 1199 }
1167 //FIXME: support 'rounding' styles 1200 //FIXME: support 'rounding' styles
1168 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1201 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1169 bY = (contentsRect().height() - (lines *font_h)) / 2; 1202 bY = (contentsRect().height() - (lines *font_h)) / 2;
1203
1204 if(showhscrollbar == 1)
1205 {
1206 //bY = bY - 10;
1207 lines = lines - 1;
1208 }
1170} 1209}
1171 1210
1172void TEWidget::makeImage() 1211void TEWidget::makeImage()
1173//FIXME: rename 'calcGeometry? 1212//FIXME: rename 'calcGeometry?
1174{ 1213{
1175 calcGeometry(); 1214 calcGeometry();
1176 image = (ca*) malloc(lines*columns*sizeof(ca)); 1215 image = (ca*) malloc(lines*columns*sizeof(ca));
1177 clearImage(); 1216 clearImage();
@@ -1296,8 +1335,15 @@ void TEWidget::drop_menu_activated(int)
1296 break; 1335 break;
1297 } 1336 }
1298#endif 1337#endif
1299} 1338}
1300 1339
1301QPushButton* TEWidget::cornerButton() { 1340QPushButton* TEWidget::cornerButton() {
1302 return m_cornerButton; 1341 return m_cornerButton;
1303} 1342}
1343
1344void TEWidget::setWrapAt(int columns)
1345{
1346 vcolumns = columns;
1347}
1348
1349
diff --git a/noncore/apps/opie-console/TEWidget.h b/noncore/apps/opie-console/TEWidget.h
index f03a16e..6ff731b 100644
--- a/noncore/apps/opie-console/TEWidget.h
+++ b/noncore/apps/opie-console/TEWidget.h
@@ -64,16 +64,18 @@ public:
64 void setScrollbarLocation(int loc); 64 void setScrollbarLocation(int loc);
65 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; 65 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
66 66
67 void setScroll(int cursor, int lines); 67 void setScroll(int cursor, int lines);
68 void doScroll(int lines); 68 void doScroll(int lines);
69 69
70 void emitSelection(); 70 void emitSelection();
71 71
72 void setWrapAt(int columns);
73
72public: 74public:
73 75
74 void setImage(const ca* const newimg, int lines, int columns); 76 void setImage(const ca* const newimg, int lines, int columns);
75 77
76 int Lines() { return lines; } 78 int Lines() { return lines; }
77 int Columns() { return columns; } 79 int Columns() { return columns; }
78 80
79 void calcGeometry(); 81 void calcGeometry();
@@ -149,16 +151,17 @@ public:
149 151
150public slots: 152public slots:
151 153
152 void onClearSelection(); 154 void onClearSelection();
153 155
154protected slots: 156protected slots:
155 157
156 void scrollChanged(int value); 158 void scrollChanged(int value);
159 void hscrollChanged(int value);
157 void blinkEvent(); 160 void blinkEvent();
158 161
159private: 162private:
160 163
161 QChar (*fontMap)(QChar); // possible vt100 font extention 164 QChar (*fontMap)(QChar); // possible vt100 font extention
162 165
163 bool fixed_font; // has fixed pitch 166 bool fixed_font; // has fixed pitch
164 int font_h; // height 167 int font_h; // height
@@ -183,18 +186,19 @@ private:
183 QPoint iPntSel; // initial selection point 186 QPoint iPntSel; // initial selection point
184 QPoint pntSel; // current selection point 187 QPoint pntSel; // current selection point
185 int actSel; // selection state 188 int actSel; // selection state
186 BOOL word_selection_mode; 189 BOOL word_selection_mode;
187 BOOL preserve_line_breaks; 190 BOOL preserve_line_breaks;
188 191
189 QPushButton *m_cornerButton; 192 QPushButton *m_cornerButton;
190 QClipboard* cb; 193 QClipboard* cb;
191 QScrollBar* scrollbar; 194 QScrollBar* scrollbar, *hscrollbar;
192 int scrollLoc; 195 int scrollLoc;
196 int hposition, vcolumns;
193 197
194//#define SCRNONE 0 198//#define SCRNONE 0
195//#define SCRLEFT 1 199//#define SCRLEFT 1
196//#define SCRRIGHT 2 200//#define SCRRIGHT 2
197 201
198 BOOL blinking; // hide text in paintEvent 202 BOOL blinking; // hide text in paintEvent
199 BOOL hasBlinker; // has characters to blink 203 BOOL hasBlinker; // has characters to blink
200 QTimer* blinkT; // active when hasBlinker 204 QTimer* blinkT; // active when hasBlinker
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index e80168d..e0f63cd 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -7,16 +7,19 @@
7#include "profile.h" 7#include "profile.h"
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9#include "script.h" 9#include "script.h"
10 10
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 12 : QObject(0, name )
13{ 13{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 14 m_teWid = new TEWidget( parent, "TerminalMain");
15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
16 // use setWrapAt(80) for normal console with scrollbar
17 m_teWid->setWrapAt(prof.readNumEntry("Wrap", 0) ? 0 : 80);
15 m_teWid->setMinimumSize(150, 70 ); 18 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0; 19 m_script = 0;
17 parent->resize( m_teWid->calcSize(80, 24 ) ); 20 parent->resize( m_teWid->calcSize(80, 24 ) );
18 m_teEmu = new TEmuVt102(m_teWid ); 21 m_teEmu = new TEmuVt102(m_teWid );
19 22
20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
21 this, SIGNAL(changeSize(int, int) ) ); 24 this, SIGNAL(changeSize(int, int) ) );
22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index d8e342b..9f95c72 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -10,19 +10,16 @@
10#include <qstring.h> 10#include <qstring.h>
11#include <qpainter.h> 11#include <qpainter.h>
12#include <qrect.h> 12#include <qrect.h>
13#include <qscrollbar.h> 13#include <qscrollbar.h>
14 14
15#define rimX 0 // left/right rim width 15#define rimX 0 // left/right rim width
16#define rimY 0 // top/bottom rim high 16#define rimY 0 // top/bottom rim high
17 17
18#define SCRWIDTH 16 // width of scrollbar
19
20
21static const ColorEntry color_table[TABLE_COLORS] = 18static const ColorEntry color_table[TABLE_COLORS] =
22{ 19{
23 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 20 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
24 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 21 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
25 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 22 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
26 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 23 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
27 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 24 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
28 // intensiv 25 // intensiv
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index d948179..10045c6 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -97,18 +97,16 @@ alter Widget to use only QByteArray, where applicable.
97#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 97#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
98 98
99#define loc(X,Y) ((Y)*columns+(X)) 99#define loc(X,Y) ((Y)*columns+(X))
100 100
101//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 101//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
102#define rimX 0 // left/right rim width 102#define rimX 0 // left/right rim width
103#define rimY 0 // top/bottom rim high 103#define rimY 0 // top/bottom rim high
104 104
105#define SCRWIDTH 16 // width of the scrollbar
106
107#define yMouseScroll 1 105#define yMouseScroll 1
108// scroll increment used when dragging selection at top/bottom of window. 106// scroll increment used when dragging selection at top/bottom of window.
109 107
110/* ------------------------------------------------------------------------- */ 108/* ------------------------------------------------------------------------- */
111/* */ 109/* */
112/* Colors */ 110/* Colors */
113/* */ 111/* */
114/* ------------------------------------------------------------------------- */ 112/* ------------------------------------------------------------------------- */