summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index d1ff85e..1c83710 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -230,256 +230,257 @@ static QChar vt100extended(QChar c)
230 case 0x00b1 : return 8; 230 case 0x00b1 : return 8;
231 case 0x2424 : return 9; 231 case 0x2424 : return 9;
232 case 0x240b : return 10; 232 case 0x240b : return 10;
233 case 0x2518 : return 11; 233 case 0x2518 : return 11;
234 case 0x2510 : return 12; 234 case 0x2510 : return 12;
235 case 0x250c : return 13; 235 case 0x250c : return 13;
236 case 0x2514 : return 14; 236 case 0x2514 : return 14;
237 case 0x253c : return 15; 237 case 0x253c : return 15;
238 case 0xf800 : return 16; 238 case 0xf800 : return 16;
239 case 0xf801 : return 17; 239 case 0xf801 : return 17;
240 case 0x2500 : return 18; 240 case 0x2500 : return 18;
241 case 0xf803 : return 19; 241 case 0xf803 : return 19;
242 case 0xf804 : return 20; 242 case 0xf804 : return 20;
243 case 0x251c : return 21; 243 case 0x251c : return 21;
244 case 0x2524 : return 22; 244 case 0x2524 : return 22;
245 case 0x2534 : return 23; 245 case 0x2534 : return 23;
246 case 0x252c : return 24; 246 case 0x252c : return 24;
247 case 0x2502 : return 25; 247 case 0x2502 : return 25;
248 case 0x2264 : return 26; 248 case 0x2264 : return 26;
249 case 0x2265 : return 27; 249 case 0x2265 : return 27;
250 case 0x03c0 : return 28; 250 case 0x03c0 : return 28;
251 case 0x2260 : return 29; 251 case 0x2260 : return 29;
252 case 0x00a3 : return 30; 252 case 0x00a3 : return 30;
253 case 0x00b7 : return 31; 253 case 0x00b7 : return 31;
254 } 254 }
255 return c; 255 return c;
256} 256}
257 257
258static QChar identicalMap(QChar c) 258static QChar identicalMap(QChar c)
259{ 259{
260 return c; 260 return c;
261} 261}
262 262
263void TEWidget::fontChange(const QFont &) 263void TEWidget::fontChange(const QFont &)
264{ 264{
265 QFontMetrics fm(font()); 265 QFontMetrics fm(font());
266 font_h = fm.height(); 266 font_h = fm.height();
267 font_w = fm.maxWidth(); 267 font_w = fm.maxWidth();
268 font_a = fm.ascent(); 268 font_a = fm.ascent();
269//printf("font_h: %d\n",font_h); 269//printf("font_h: %d\n",font_h);
270//printf("font_w: %d\n",font_w); 270//printf("font_w: %d\n",font_w);
271//printf("font_a: %d\n",font_a); 271//printf("font_a: %d\n",font_a);
272//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 272//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
273//printf("rawname: %s\n",font().rawName().ascii()); 273//printf("rawname: %s\n",font().rawName().ascii());
274 fontMap = 274 fontMap =
275#if QT_VERSION < 300 275#if QT_VERSION < 300
276 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 276 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
277 ? vt100extended 277 ? vt100extended
278 : 278 :
279#endif 279#endif
280 identicalMap; 280 identicalMap;
281 propagateSize(); 281 propagateSize();
282 update(); 282 update();
283} 283}
284 284
285void TEWidget::setVTFont(const QFont& f) 285void TEWidget::setVTFont(const QFont& f)
286{ 286{
287 QFrame::setFont(f); 287 QFrame::setFont(f);
288} 288}
289 289
290QFont TEWidget::getVTFont() { 290QFont TEWidget::getVTFont() {
291 return font(); 291 return font();
292} 292}
293 293
294void TEWidget::setFont(const QFont &) 294void TEWidget::setFont(const QFont &)
295{ 295{
296 // ignore font change request if not coming from konsole itself 296 // ignore font change request if not coming from konsole itself
297} 297}
298 298
299/* ------------------------------------------------------------------------- */ 299/* ------------------------------------------------------------------------- */
300/* */ 300/* */
301/* Constructor / Destructor */ 301/* Constructor / Destructor */
302/* */ 302/* */
303/* ----------------------------------------------------------------------- */ 303/* ----------------------------------------------------------------------- */
304 304
305 305
306 306
307TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 307TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
308{ 308{
309#ifndef QT_NO_CLIPBOARD 309#ifndef QT_NO_CLIPBOARD
310 cb = QApplication::clipboard(); 310 cb = QApplication::clipboard();
311 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 311 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
312 this, SLOT(onClearSelection()) ); 312 this, SLOT(onClearSelection()) );
313#endif 313#endif
314 314
315 315
316 scrollbar = new QScrollBar( this ); 316 scrollbar = new QScrollBar( this );
317 scrollbar->setCursor( arrowCursor ); 317 scrollbar->setCursor( arrowCursor );
318 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 318 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
319 319
320 hscrollbar = new QScrollBar( Qt::Horizontal, this ); 320 hscrollbar = new QScrollBar( Qt::Horizontal, this );
321 hscrollbar->setCursor( arrowCursor ); 321 hscrollbar->setCursor( arrowCursor );
322 connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int))); 322 connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int)));
323 323
324 m_cornerButton = new QPushButton( this ); 324 m_cornerButton = new QPushButton( this );
325 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 325 m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
326 m_cornerButton->setMaximumSize( 14, 14 ); 326 m_cornerButton->setMaximumSize( 14, 14 );
327 m_cornerButton->hide(); 327 m_cornerButton->hide();
328 328
329 Config cfg("Konsole"); 329 Config cfg("Konsole");
330 cfg.setGroup("ScrollBar"); 330 cfg.setGroup("ScrollBar");
331 switch( cfg.readNumEntry("Position",2)){ 331 switch( cfg.readNumEntry("Position",2)){
332 case 0: 332 case 0:
333 scrollLoc = SCRNONE; 333 scrollLoc = SCRNONE;
334 break; 334 break;
335 case 1: 335 case 1:
336 scrollLoc = SCRLEFT; 336 scrollLoc = SCRLEFT;
337 break; 337 break;
338 case 2: 338 case 2:
339 scrollLoc = SCRRIGHT; 339 scrollLoc = SCRRIGHT;
340 break; 340 break;
341 }; 341 };
342 342
343 blinkT = new QTimer(this); 343 blinkT = new QTimer(this);
344 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 344 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
345 // blinking = FALSE; 345 // blinking = FALSE;
346 blinking = TRUE; 346 blinking = TRUE;
347 347
348 resizing = FALSE; 348 resizing = FALSE;
349 actSel = 0; 349 actSel = 0;
350 image = 0; 350 image = 0;
351 lines = 1; 351 lines = 1;
352 columns = 1; 352 columns = 1;
353 font_w = 1; 353 font_w = 1;
354 font_h = 1; 354 font_h = 1;
355 font_a = 1; 355 font_a = 1;
356 word_selection_mode = FALSE; 356 word_selection_mode = FALSE;
357 vcolumns = 0; 357 vcolumns = 0;
358 hposition = 0;
358 359
359 setMouseMarks(TRUE); 360 setMouseMarks(TRUE);
360 setVTFont( QFont("fixed") ); 361 setVTFont( QFont("fixed") );
361 setColorTable(base_color_table); // init color table 362 setColorTable(base_color_table); // init color table
362 363
363 qApp->installEventFilter( this ); //FIXME: see below 364 qApp->installEventFilter( this ); //FIXME: see below
364// KCursor::setAutoHideCursor( this, true ); 365// KCursor::setAutoHideCursor( this, true );
365 366
366 // Init DnD //////////////////////////////////////////////////////////////// 367 // Init DnD ////////////////////////////////////////////////////////////////
367 currentSession = NULL; 368 currentSession = NULL;
368// setAcceptDrops(true); // attempt 369// setAcceptDrops(true); // attempt
369// m_drop = new QPopupMenu(this); 370// m_drop = new QPopupMenu(this);
370// m_drop->insertItem( QString("Paste"), 0); 371// m_drop->insertItem( QString("Paste"), 0);
371// m_drop->insertItem( QString("cd"), 1); 372// m_drop->insertItem( QString("cd"), 1);
372// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 373// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
373 374
374 // we need focus so that the auto-hide cursor feature works 375 // we need focus so that the auto-hide cursor feature works
375 setFocus(); 376 setFocus();
376 setFocusPolicy( WheelFocus ); 377 setFocusPolicy( WheelFocus );
377} 378}
378 379
379//FIXME: make proper destructor 380//FIXME: make proper destructor
380// Here's a start (David) 381// Here's a start (David)
381TEWidget::~TEWidget() 382TEWidget::~TEWidget()
382{ 383{
383 qApp->removeEventFilter( this ); 384 qApp->removeEventFilter( this );
384 if (image) free(image); 385 if (image) free(image);
385} 386}
386 387
387/* ------------------------------------------------------------------------- */ 388/* ------------------------------------------------------------------------- */
388/* */ 389/* */
389/* Display Operations */ 390/* Display Operations */
390/* */ 391/* */
391/* ------------------------------------------------------------------------- */ 392/* ------------------------------------------------------------------------- */
392 393
393/*! 394/*!
394 attributed string draw primitive 395 attributed string draw primitive
395*/ 396*/
396 397
397void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 398void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
398 QString& str, ca attr, BOOL pm, BOOL clear) 399 QString& str, ca attr, BOOL pm, BOOL clear)
399{ 400{
400 if (pm && color_table[attr.b].transparent) 401 if (pm && color_table[attr.b].transparent)
401 { 402 {
402 paint.setBackgroundMode( TransparentMode ); 403 paint.setBackgroundMode( TransparentMode );
403 if (clear) erase(rect); 404 if (clear) erase(rect);
404 } 405 }
405 else 406 else
406 { 407 {
407 if (blinking) 408 if (blinking)
408 paint.fillRect(rect, color_table[attr.b].color); 409 paint.fillRect(rect, color_table[attr.b].color);
409 else 410 else
410 { 411 {
411 paint.setBackgroundMode( OpaqueMode ); 412 paint.setBackgroundMode( OpaqueMode );
412 paint.setBackgroundColor( color_table[attr.b].color ); 413 paint.setBackgroundColor( color_table[attr.b].color );
413 } 414 }
414 } 415 }
415 416
416 if (color_table[attr.f].bold) 417 if (color_table[attr.f].bold)
417 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 418 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
418 else 419 else
419 paint.setPen(color_table[attr.f].color); 420 paint.setPen(color_table[attr.f].color);
420 421
421 paint.drawText(rect.x(),rect.y()+font_a, str); 422 paint.drawText(rect.x(),rect.y()+font_a, str);
422 423
423 if (attr.r & RE_UNDERLINE) 424 if (attr.r & RE_UNDERLINE)
424 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 425 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
425} 426}
426 427
427/*! 428/*!
428 The image can only be set completely. 429 The image can only be set completely.
429 430
430 The size of the new image may or may not match the size of the widget. 431 The size of the new image may or may not match the size of the widget.
431*/ 432*/
432 433
433void TEWidget::setImage(const ca* const newimg, int lines, int columns) 434void TEWidget::setImage(const ca* const newimg, int lines, int columns)
434{ int y,x,len; 435{ int y,x,len;
435 const QPixmap* pm = backgroundPixmap(); 436 const QPixmap* pm = backgroundPixmap();
436 QPainter paint; 437 QPainter paint;
437 setUpdatesEnabled(FALSE); 438 setUpdatesEnabled(FALSE);
438 paint.begin( this ); 439 paint.begin( this );
439HCNT("setImage"); 440HCNT("setImage");
440 441
441 QPoint tL = contentsRect().topLeft(); 442 QPoint tL = contentsRect().topLeft();
442 int tLx = tL.x(); 443 int tLx = tL.x();
443 int tLy = tL.y(); 444 int tLy = tL.y();
444 hasBlinker = FALSE; 445 hasBlinker = FALSE;
445 446
446 int cf = -1; // undefined 447 int cf = -1; // undefined
447 int cb = -1; // undefined 448 int cb = -1; // undefined
448 int cr = -1; // undefined 449 int cr = -1; // undefined
449 450
450 int lins = QMIN(this->lines, QMAX(0,lines )); 451 int lins = QMIN(this->lines, QMAX(0,lines ));
451 int cols = QMIN(this->columns,QMAX(0,columns)); 452 int cols = QMIN(this->columns,QMAX(0,columns));
452 QChar *disstrU = new QChar[cols]; 453 QChar *disstrU = new QChar[cols];
453 454
454//{ static int cnt = 0; printf("setImage %d\n",cnt++); } 455//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
455 for (y = 0; y < lins; y++) 456 for (y = 0; y < lins; y++)
456 { 457 {
457 const ca* lcl = &image[y*this->columns]; 458 const ca* lcl = &image[y*this->columns];
458 const ca* const ext = &newimg[y*columns]; 459 const ca* const ext = &newimg[y*columns];
459 if (!resizing) // not while resizing, we're expecting a paintEvent 460 if (!resizing) // not while resizing, we're expecting a paintEvent
460 for (x = 0; x < cols; x++) 461 for (x = 0; x < cols; x++)
461 { 462 {
462 hasBlinker |= (ext[x].r & RE_BLINK); 463 hasBlinker |= (ext[x].r & RE_BLINK);
463 if (ext[x] != lcl[x]) 464 if (ext[x] != lcl[x])
464 { 465 {
465 cr = ext[x].r; 466 cr = ext[x].r;
466 cb = ext[x].b; 467 cb = ext[x].b;
467 if (ext[x].f != cf) cf = ext[x].f; 468 if (ext[x].f != cf) cf = ext[x].f;
468 int lln = cols - x; 469 int lln = cols - x;
469 disstrU[0] = fontMap(ext[x+0].c); 470 disstrU[0] = fontMap(ext[x+0].c);
470 for (len = 1; len < lln; len++) 471 for (len = 1; len < lln; len++)
471 { 472 {
472 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 473 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
473 ext[x+len] == lcl[x+len] ) 474 ext[x+len] == lcl[x+len] )
474 break; 475 break;
475 disstrU[len] = fontMap(ext[x+len].c); 476 disstrU[len] = fontMap(ext[x+len].c);
476 } 477 }
477 QString unistr(disstrU,len); 478 QString unistr(disstrU,len);
478 drawAttrStr(paint, 479 drawAttrStr(paint,
479 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 480 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
480 unistr, ext[x], pm != NULL, true); 481 unistr, ext[x], pm != NULL, true);
481 x += len - 1; 482 x += len - 1;
482 } 483 }
483 } 484 }
484 // finally, make `image' become `newimg'. 485 // finally, make `image' become `newimg'.
485 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 486 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));