summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index 318d7bb..e11c5e4 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -1,248 +1,248 @@
1// opie-console includes 1// opie-console includes
2#include "emulation_widget.h" 2#include "emulation_widget.h"
3#include "common.h" 3#include "common.h"
4#include "widget_layer.h" 4#include "widget_layer.h"
5#include "profile.h" 5#include "profile.h"
6 6
7// qt includes 7// qt includes
8#include <qwidget.h> 8#include <qwidget.h>
9#include <qarray.h> 9#include <qarray.h>
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 18#define SCRWIDTH 16 // width of scrollbar
19 19
20EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) 20EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name )
21{ 21{
22 22
23 // initialize font attributes 23 // initialize font attributes
24 QFontMetrics fm( font() ); 24 QFontMetrics fm( font() );
25 f_height = fm.height(); 25 f_height = fm.height();
26 f_width = fm.maxWidth(); 26 f_width = fm.maxWidth();
27 f_ascent = fm.ascent(); 27 f_ascent = fm.ascent();
28 28
29 // give reasonable defaults to m_columns, m_lines
30 calcGeometry();
31
32 // initialize scrollbar related vars 29 // initialize scrollbar related vars
33 m_scrollbar = new QScrollBar( this ); 30 m_scrollbar = new QScrollBar( this );
34 m_scrollbar->setCursor( arrowCursor ); 31 m_scrollbar->setCursor( arrowCursor );
35 32
33 // give reasonable defaults to m_columns, m_lines
34 calcGeometry();
35
36 // load config 36 // load config
37 reloadConfig( config ); 37 reloadConfig( config );
38 38
39 m_resizing = false; 39 m_resizing = false;
40} 40}
41 41
42void EmulationWidget::reloadConfig( const Profile& config ) 42void EmulationWidget::reloadConfig( const Profile& config )
43{ 43{
44 44
45 // nothing yet 45 // nothing yet
46} 46}
47 47
48EmulationWidget::~EmulationWidget() 48EmulationWidget::~EmulationWidget()
49{ 49{
50 //clean up 50 //clean up
51} 51}
52 52
53static QChar vt100extended(QChar c) 53static QChar vt100extended(QChar c)
54{ 54{
55 switch (c.unicode()) 55 switch (c.unicode())
56 { 56 {
57 case 0x25c6 : return 1; 57 case 0x25c6 : return 1;
58 case 0x2592 : return 2; 58 case 0x2592 : return 2;
59 case 0x2409 : return 3; 59 case 0x2409 : return 3;
60 case 0x240c : return 4; 60 case 0x240c : return 4;
61 case 0x240d : return 5; 61 case 0x240d : return 5;
62 case 0x240a : return 6; 62 case 0x240a : return 6;
63 case 0x00b0 : return 7; 63 case 0x00b0 : return 7;
64 case 0x00b1 : return 8; 64 case 0x00b1 : return 8;
65 case 0x2424 : return 9; 65 case 0x2424 : return 9;
66 case 0x240b : return 10; 66 case 0x240b : return 10;
67 case 0x2518 : return 11; 67 case 0x2518 : return 11;
68 case 0x2510 : return 12; 68 case 0x2510 : return 12;
69 case 0x250c : return 13; 69 case 0x250c : return 13;
70 case 0x2514 : return 14; 70 case 0x2514 : return 14;
71 case 0x253c : return 15; 71 case 0x253c : return 15;
72 case 0xf800 : return 16; 72 case 0xf800 : return 16;
73 case 0xf801 : return 17; 73 case 0xf801 : return 17;
74 case 0x2500 : return 18; 74 case 0x2500 : return 18;
75 case 0xf803 : return 19; 75 case 0xf803 : return 19;
76 case 0xf804 : return 20; 76 case 0xf804 : return 20;
77 case 0x251c : return 21; 77 case 0x251c : return 21;
78 case 0x2524 : return 22; 78 case 0x2524 : return 22;
79 case 0x2534 : return 23; 79 case 0x2534 : return 23;
80 case 0x252c : return 24; 80 case 0x252c : return 24;
81 case 0x2502 : return 25; 81 case 0x2502 : return 25;
82 case 0x2264 : return 26; 82 case 0x2264 : return 26;
83 case 0x2265 : return 27; 83 case 0x2265 : return 27;
84 case 0x03c0 : return 28; 84 case 0x03c0 : return 28;
85 case 0x2260 : return 29; 85 case 0x2260 : return 29;
86 case 0x00a3 : return 30; 86 case 0x00a3 : return 30;
87 case 0x00b7 : return 31; 87 case 0x00b7 : return 31;
88 } 88 }
89 return c; 89 return c;
90} 90}
91 91
92 92
93 93
94void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) 94void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns )
95{ 95{
96 const QPixmap* pm = backgroundPixmap(); 96 const QPixmap* pm = backgroundPixmap();
97 QPainter paint; 97 QPainter paint;
98 98
99 // dont allow updates, while drawing 99 // dont allow updates, while drawing
100 setUpdatesEnabled( false ); 100 setUpdatesEnabled( false );
101 101
102 paint.begin( this ); 102 paint.begin( this );
103 103
104 QPoint tL = contentsRect().topLeft(); 104 QPoint tL = contentsRect().topLeft();
105 int tLx = tL.x(); 105 int tLx = tL.x();
106 int tLy = tL.y(); 106 int tLy = tL.y();
107 //hasBlinker = false; 107 //hasBlinker = false;
108 108
109 int cf = -1; 109 int cf = -1;
110 int cb = -1; 110 int cb = -1;
111 int cr = -1; 111 int cr = -1;
112 112
113 int lins = QMIN( m_lines, QMAX( 0, lines ) ); 113 int lins = QMIN( m_lines, QMAX( 0, lines ) );
114 int cols = QMIN( m_columns, QMAX( 0, columns ) ); 114 int cols = QMIN( m_columns, QMAX( 0, columns ) );
115 QArray<QChar> disstrU = QArray<QChar>( cols ); 115 QArray<QChar> disstrU = QArray<QChar>( cols );
116 116
117 for ( int y = 0; y < lins; ++y ) 117 for ( int y = 0; y < lins; ++y )
118 {int len; 118 {int len;
119 const Character* lcl = &m_image[y * m_columns]; 119 const Character* lcl = &m_image[y * m_columns];
120 const Character* ext = &newimg[y * columns]; 120 const Character* ext = &newimg[y * columns];
121 if ( ! m_resizing ) 121 if ( ! m_resizing )
122 for ( int x = 0; x < cols; ++x ) 122 for ( int x = 0; x < cols; ++x )
123 { 123 {
124 // disable, till widget works, WITHOUT blinking 124 // disable, till widget works, WITHOUT blinking
125 //hasBlinker |= ( ext[x].r & RE_BLINK ); 125 //hasBlinker |= ( ext[x].r & RE_BLINK );
126 126
127 if ( ext[x] != lcl[x] ) 127 if ( ext[x] != lcl[x] )
128 { 128 {
129 cr = ext[x].r; 129 cr = ext[x].r;
130 cb = ext[x].b; 130 cb = ext[x].b;
131 if ( ext[x].f != cf ) cf = ext[x].f; 131 if ( ext[x].f != cf ) cf = ext[x].f;
132 int lln = cols - x; 132 int lln = cols - x;
133 disstrU[0] = vt100extended( ext[x+0].c ); 133 disstrU[0] = vt100extended( ext[x+0].c );
134 for ( len = 1; len < lln; ++len ) 134 for ( len = 1; len < lln; ++len )
135 { 135 {
136 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) 136 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] )
137 break; 137 break;
138 disstrU[len] = vt100extended( ext[x+len].c ); 138 disstrU[len] = vt100extended( ext[x+len].c );
139 } 139 }
140 QString unistr( disstrU, len ); 140 QString unistr( disstrU, len );
141 drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); 141 drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true );
142 x += len -1; 142 x += len -1;
143 } 143 }
144 } 144 }
145 // make image become newimg 145 // make image become newimg
146 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); 146 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) );
147 } 147 }
148 drawFrame( &paint ); 148 drawFrame( &paint );
149 paint.end(); 149 paint.end();
150 setUpdatesEnabled( true ); 150 setUpdatesEnabled( true );
151 151
152 /*if ( hasBlinker && !blinkT->isActive() ) 152 /*if ( hasBlinker && !blinkT->isActive() )
153 blinkT->start(1000); //ms 153 blinkT->start(1000); //ms
154 if ( ! hasBlinker && blinkT->isActive() ) 154 if ( ! hasBlinker && blinkT->isActive() )
155 { 155 {
156 blinkT->stop(); 156 blinkT->stop();
157 blinking = false; 157 blinking = false;
158 }*/ 158 }*/
159 159
160 delete [] disstrU; 160 delete [] disstrU;
161} 161}
162 162
163void EmulationWidget::calcGeometry() 163void EmulationWidget::calcGeometry()
164{ 164{
165 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); 165 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
166 166
167 switch( scrollLoc ) 167 switch( scrollLoc )
168 { 168 {
169 case SCRNONE : 169 case SCRNONE :
170 m_columns = ( contentsRect().width() -2 * rimX ) / f_width; 170 m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
171 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; 171 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
172 m_brX = m_blX; 172 m_brX = m_blX;
173 m_scrollbar->hide(); 173 m_scrollbar->hide();
174 break; 174 break;
175 case SCRLEFT : 175 case SCRLEFT :
176 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 176 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
177 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 177 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
178 m_blX = m_brX + m_scrollbar->width(); 178 m_blX = m_brX + m_scrollbar->width();
179 m_scrollbar->move( contentsRect().topLeft() ); 179 m_scrollbar->move( contentsRect().topLeft() );
180 m_scrollbar->show(); 180 m_scrollbar->show();
181 break; 181 break;
182 case SCRIGHT: 182 case SCRIGHT:
183 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 183 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
184 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 184 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
185 m_brX = m_blX; 185 m_brX = m_blX;
186 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); 186 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) );
187 m_scrollbar->show(); 187 m_scrollbar->show();
188 break; 188 break;
189 } 189 }
190 190
191 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; 191 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
192 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; 192 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
193} 193}
194 194
195void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) 195void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
196{ 196{
197 if ( usePixmap && color_table[attr.b].transparent ) 197 if ( usePixmap && color_table[attr.b].transparent )
198 { 198 {
199 painter.setBackgroundMode( TransparentMode ); 199 painter.setBackgroundMode( TransparentMode );
200 if ( clear ) 200 if ( clear )
201 erase( rect ); 201 erase( rect );
202 } 202 }
203 else 203 else
204 { 204 {
205 if ( blinking ) 205 if ( blinking )
206 painter.fillRect( rect, color_table[attr.b].color ); 206 painter.fillRect( rect, color_table[attr.b].color );
207 else 207 else
208 { 208 {
209 painter.setBackgroundMode( OpaqueMode ); 209 painter.setBackgroundMode( OpaqueMode );
210 painter.setBackgroundColor( color_table[attr.b].color ); 210 painter.setBackgroundColor( color_table[attr.b].color );
211 } 211 }
212 } 212 }
213 if ( color_table[attr.f].bold ) 213 if ( color_table[attr.f].bold )
214 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); 214 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
215 else 215 else
216 painter.setPen( color_table[attr.f].color ); 216 painter.setPen( color_table[attr.f].color );
217 painter.drawText( rect.x(), rect.y() + f_ascent, string ); 217 painter.drawText( rect.x(), rect.y() + f_ascent, string );
218 218
219} 219}
220 220
221 221
222/////////////////////// 222///////////////////////
223// scrollbar 223// scrollbar
224// //////////////////// 224// ////////////////////
225 225
226void EmulationWidget::scroll( int value ) 226void EmulationWidget::scroll( int value )
227{ 227{
228} 228}
229 229
230void EmulationWidget::setScroll( int cursor, int slines ) 230void EmulationWidget::setScroll( int cursor, int slines )
231{ 231{
232} 232}
233 233
234 234
235static const ColorEntry color_table[TABLE_COLORS] = 235static const ColorEntry color_table[TABLE_COLORS] =
236{ 236{
237 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 237 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
238 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 238 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
239 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 239 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
240 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 240 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
241 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 241 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
242 // intensiv 242 // intensiv
243 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 243 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
244 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 244 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
245 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 245 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
246 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 246 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
247 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 247 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
248}; 248};