-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 60 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 63 |
2 files changed, 3 insertions, 120 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp index 50807d3..a6cf6a1 100644 --- a/core/apps/embeddedkonsole/TEScreen.cpp +++ b/core/apps/embeddedkonsole/TEScreen.cpp | |||
@@ -360,443 +360,385 @@ void TEScreen::saveCursor() | |||
360 | /*! Restore the cursor position and the rendition attribute settings. */ | 360 | /*! Restore the cursor position and the rendition attribute settings. */ |
361 | 361 | ||
362 | void TEScreen::restoreCursor() | 362 | void TEScreen::restoreCursor() |
363 | { | 363 | { |
364 | cuX = QMIN(sa_cuX,columns-1); | 364 | cuX = QMIN(sa_cuX,columns-1); |
365 | cuY = QMIN(sa_cuY,lines-1); | 365 | cuY = QMIN(sa_cuY,lines-1); |
366 | cu_re = sa_cu_re; | 366 | cu_re = sa_cu_re; |
367 | cu_fg = sa_cu_fg; | 367 | cu_fg = sa_cu_fg; |
368 | cu_bg = sa_cu_bg; | 368 | cu_bg = sa_cu_bg; |
369 | effectiveRendition(); | 369 | effectiveRendition(); |
370 | } | 370 | } |
371 | 371 | ||
372 | /* ------------------------------------------------------------------------- */ | 372 | /* ------------------------------------------------------------------------- */ |
373 | /* */ | 373 | /* */ |
374 | /* Screen Operations */ | 374 | /* Screen Operations */ |
375 | /* */ | 375 | /* */ |
376 | /* ------------------------------------------------------------------------- */ | 376 | /* ------------------------------------------------------------------------- */ |
377 | 377 | ||
378 | /*! Assing a new size to the screen. | 378 | /*! Assing a new size to the screen. |
379 | 379 | ||
380 | The topmost left position is maintained, while lower lines | 380 | The topmost left position is maintained, while lower lines |
381 | or right hand side columns might be removed or filled with | 381 | or right hand side columns might be removed or filled with |
382 | spaces to fit the new size. | 382 | spaces to fit the new size. |
383 | 383 | ||
384 | The region setting is reset to the whole screen and the | 384 | The region setting is reset to the whole screen and the |
385 | tab positions reinitialized. | 385 | tab positions reinitialized. |
386 | */ | 386 | */ |
387 | 387 | ||
388 | void TEScreen::resizeImage(int new_lines, int new_columns) | 388 | void TEScreen::resizeImage(int new_lines, int new_columns) |
389 | { | 389 | { |
390 | if (cuY > new_lines-1) { | 390 | if (cuY > new_lines-1) { |
391 | // attempt to preserve focus and lines | 391 | // attempt to preserve focus and lines |
392 | bmargin = lines-1; //FIXME: margin lost | 392 | bmargin = lines-1; //FIXME: margin lost |
393 | for (int i = 0; i < cuY-(new_lines-1); i++) { | 393 | for (int i = 0; i < cuY-(new_lines-1); i++) { |
394 | addHistLine(); scrollUp(horzCursor,1); | 394 | addHistLine(); scrollUp(horzCursor,1); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // make new image | 398 | // make new image |
399 | ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); | 399 | ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); |
400 | 400 | ||
401 | clearSelection(); | 401 | clearSelection(); |
402 | 402 | ||
403 | // clear new image | 403 | // clear new image |
404 | for (int y = 0; y < new_lines; y++) | 404 | for (int y = 0; y < new_lines; y++) |
405 | for (int x = 0; x < new_columns; x++) { | 405 | for (int x = 0; x < new_columns; x++) { |
406 | newimg[y*new_columns+x].c = ' '; | 406 | newimg[y*new_columns+x].c = ' '; |
407 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; | 407 | newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; |
408 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; | 408 | newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; |
409 | newimg[y*new_columns+x].r = DEFAULT_RENDITION; | 409 | newimg[y*new_columns+x].r = DEFAULT_RENDITION; |
410 | } | 410 | } |
411 | int cpy_lines = QMIN(new_lines, lines); | 411 | int cpy_lines = QMIN(new_lines, lines); |
412 | int cpy_columns = QMIN(new_columns,columns); | 412 | int cpy_columns = QMIN(new_columns,columns); |
413 | // copy to new image | 413 | // copy to new image |
414 | for (int y = 0; y < cpy_lines; y++) | 414 | for (int y = 0; y < cpy_lines; y++) |
415 | for (int x = 0; x < cpy_columns; x++) { | 415 | for (int x = 0; x < cpy_columns; x++) { |
416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; | 416 | newimg[y*new_columns+x].c = image[loc(x,y)].c; |
417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; | 417 | newimg[y*new_columns+x].f = image[loc(x,y)].f; |
418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; | 418 | newimg[y*new_columns+x].b = image[loc(x,y)].b; |
419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; | 419 | newimg[y*new_columns+x].r = image[loc(x,y)].r; |
420 | } | 420 | } |
421 | free(image); | 421 | free(image); |
422 | image = newimg; | 422 | image = newimg; |
423 | lines = new_lines; | 423 | lines = new_lines; |
424 | columns = new_columns; | 424 | columns = new_columns; |
425 | cuX = QMIN(cuX,columns-1); | 425 | cuX = QMIN(cuX,columns-1); |
426 | cuY = QMIN(cuY,lines-1); | 426 | cuY = QMIN(cuY,lines-1); |
427 | 427 | ||
428 | // FIXME: try to keep values, evtl. | 428 | // FIXME: try to keep values, evtl. |
429 | tmargin=0; | 429 | tmargin=0; |
430 | bmargin=lines-1; | 430 | bmargin=lines-1; |
431 | initTabStops(); | 431 | initTabStops(); |
432 | clearSelection(); | 432 | clearSelection(); |
433 | } | 433 | } |
434 | 434 | ||
435 | /* | 435 | /* |
436 | Clarifying rendition here and in TEWidget. | 436 | Clarifying rendition here and in TEWidget. |
437 | 437 | ||
438 | currently, TEWidget's color table is | 438 | currently, TEWidget's color table is |
439 | 0 1 2 .. 9 10 .. 17 | 439 | 0 1 2 .. 9 10 .. 17 |
440 | dft_fg, dft_bg, dim 0..7, intensive 0..7 | 440 | dft_fg, dft_bg, dim 0..7, intensive 0..7 |
441 | 441 | ||
442 | cu_fg, cu_bg contain values 0..8; | 442 | cu_fg, cu_bg contain values 0..8; |
443 | - 0 = default color | 443 | - 0 = default color |
444 | - 1..8 = ansi specified color | 444 | - 1..8 = ansi specified color |
445 | 445 | ||
446 | re_fg, re_bg contain values 0..17 | 446 | re_fg, re_bg contain values 0..17 |
447 | due to the TEWidget's color table | 447 | due to the TEWidget's color table |
448 | 448 | ||
449 | rendition attributes are | 449 | rendition attributes are |
450 | 450 | ||
451 | attr widget screen | 451 | attr widget screen |
452 | -------------- ------ ------ | 452 | -------------- ------ ------ |
453 | RE_UNDERLINE XX XX affects foreground only | 453 | RE_UNDERLINE XX XX affects foreground only |
454 | RE_BLINK XX XX affects foreground only | 454 | RE_BLINK XX XX affects foreground only |
455 | RE_BOLD XX XX affects foreground only | 455 | RE_BOLD XX XX affects foreground only |
456 | RE_REVERSE -- XX | 456 | RE_REVERSE -- XX |
457 | RE_TRANSPARENT XX -- affects background only | 457 | RE_TRANSPARENT XX -- affects background only |
458 | RE_INTENSIVE XX -- affects foreground only | 458 | RE_INTENSIVE XX -- affects foreground only |
459 | 459 | ||
460 | Note that RE_BOLD is used in both widget | 460 | Note that RE_BOLD is used in both widget |
461 | and screen rendition. Since xterm/vt102 | 461 | and screen rendition. Since xterm/vt102 |
462 | is to poor to distinguish between bold | 462 | is to poor to distinguish between bold |
463 | (which is a font attribute) and intensive | 463 | (which is a font attribute) and intensive |
464 | (which is a color attribute), we translate | 464 | (which is a color attribute), we translate |
465 | this and RE_BOLD in falls eventually appart | 465 | this and RE_BOLD in falls eventually appart |
466 | into RE_BOLD and RE_INTENSIVE. | 466 | into RE_BOLD and RE_INTENSIVE. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | void TEScreen::reverseRendition(ca* p) | 469 | void TEScreen::reverseRendition(ca* p) |
470 | { UINT8 f = p->f; UINT8 b = p->b; | 470 | { UINT8 f = p->f; UINT8 b = p->b; |
471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; | 471 | p->f = b; p->b = f; //p->r &= ~RE_TRANSPARENT; |
472 | } | 472 | } |
473 | 473 | ||
474 | void TEScreen::effectiveRendition() | 474 | void TEScreen::effectiveRendition() |
475 | // calculate rendition | 475 | // calculate rendition |
476 | { | 476 | { |
477 | ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); | 477 | ef_re = cu_re & (RE_UNDERLINE | RE_BLINK); |
478 | if (cu_re & RE_REVERSE) | 478 | if (cu_re & RE_REVERSE) |
479 | { | 479 | { |
480 | ef_fg = cu_bg; | 480 | ef_fg = cu_bg; |
481 | ef_bg = cu_fg; | 481 | ef_bg = cu_fg; |
482 | } | 482 | } |
483 | else | 483 | else |
484 | { | 484 | { |
485 | ef_fg = cu_fg; | 485 | ef_fg = cu_fg; |
486 | ef_bg = cu_bg; | 486 | ef_bg = cu_bg; |
487 | } | 487 | } |
488 | if (cu_re & RE_BOLD) | 488 | if (cu_re & RE_BOLD) |
489 | { | 489 | { |
490 | if (ef_fg < BASE_COLORS) | 490 | if (ef_fg < BASE_COLORS) |
491 | ef_fg += BASE_COLORS; | 491 | ef_fg += BASE_COLORS; |
492 | else | 492 | else |
493 | ef_fg -= BASE_COLORS; | 493 | ef_fg -= BASE_COLORS; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | /*! | 497 | /*! |
498 | returns the image. | 498 | returns the image. |
499 | 499 | ||
500 | Get the size of the image by \sa getLines and \sa getColumns. | 500 | Get the size of the image by \sa getLines and \sa getColumns. |
501 | 501 | ||
502 | NOTE that the image returned by this function must later be | 502 | NOTE that the image returned by this function must later be |
503 | freed. | 503 | freed. |
504 | 504 | ||
505 | */ | 505 | */ |
506 | 506 | ||
507 | ca* TEScreen::getCookedImage() | 507 | ca* TEScreen::getCookedImage() |
508 | { | 508 | { |
509 | int x,y; | 509 | int x,y; |
510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); | 510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); |
511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | 511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); |
512 | 512 | ||
513 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) | 513 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) |
514 | { | 514 | { |
515 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); | 515 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); |
516 | int yp = y*columns; | 516 | int yp = y*columns; |
517 | int yq = (y+histCursor)*columns; | 517 | int yq = (y+histCursor)*columns; |
518 | 518 | ||
519 | hist.getCells(y+histCursor,0,len,merged+yp); | 519 | hist.getCells(y+histCursor,0,len,merged+yp); |
520 | for (x = len; x < columns; x++) merged[yp+x] = dft; | 520 | for (x = len; x < columns; x++) merged[yp+x] = dft; |
521 | for (x = 0; x < columns; x++) | 521 | for (x = 0; x < columns; x++) |
522 | { int p=x + yp; int q=x + yq; | 522 | { int p=x + yp; int q=x + yq; |
523 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) | 523 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) |
524 | reverseRendition(&merged[p]); // for selection | 524 | reverseRendition(&merged[p]); // for selection |
525 | } | 525 | } |
526 | } | 526 | } |
527 | if (lines >= hist.getLines()-histCursor) | 527 | if (lines >= hist.getLines()-histCursor) |
528 | { | 528 | { |
529 | for (y = (hist.getLines()-histCursor); y < lines ; y++) | 529 | for (y = (hist.getLines()-histCursor); y < lines ; y++) |
530 | { | 530 | { |
531 | int yp = y*columns; | 531 | int yp = y*columns; |
532 | int yq = (y+histCursor)*columns; | 532 | int yq = (y+histCursor)*columns; |
533 | int yr = (y-hist.getLines()+histCursor)*columns; | 533 | int yr = (y-hist.getLines()+histCursor)*columns; |
534 | for (x = 0; x < columns; x++) | 534 | for (x = 0; x < columns; x++) |
535 | { int p = x + yp; int q = x + yq; int r = x + yr; | 535 | { int p = x + yp; int q = x + yq; int r = x + yr; |
536 | merged[p] = image[r]; | 536 | merged[p] = image[r]; |
537 | if ( q >= sel_TL && q <= sel_BR ) | 537 | if ( q >= sel_TL && q <= sel_BR ) |
538 | reverseRendition(&merged[p]); // for selection | 538 | reverseRendition(&merged[p]); // for selection |
539 | } | 539 | } |
540 | 540 | ||
541 | } | 541 | } |
542 | } | 542 | } |
543 | // evtl. inverse display | 543 | // evtl. inverse display |
544 | if (getMode(MODE_Screen)) | 544 | if (getMode(MODE_Screen)) |
545 | { int i,n = lines*columns; | 545 | { int i,n = lines*columns; |
546 | for (i = 0; i < n; i++) | 546 | for (i = 0; i < n; i++) |
547 | reverseRendition(&merged[i]); // for reverse display | 547 | reverseRendition(&merged[i]); // for reverse display |
548 | } | 548 | } |
549 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible | 549 | if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible |
550 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); | 550 | reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); |
551 | return merged; | 551 | return merged; |
552 | 552 | ||
553 | /* | ||
554 | int x, y, z; | ||
555 | |||
556 | ca* merged = (ca*)malloc( lines * columns * sizeof( ca)); | ||
557 | |||
558 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | ||
559 | |||
560 | // qDebug("hist lines %d, historyCursor %d, minus %d ,lines %d, columns %d", | ||
561 | // hist.getLines(), histCursor, hist.getLines() - histCursor , lines, columns); | ||
562 | for (y = 0; (y < lines) && (y < ( hist.getLines() - histCursor )); y++) { | ||
563 | |||
564 | int len = QMIN( columns, hist.getLineLen( y + histCursor) ); | ||
565 | int yp = y * columns; | ||
566 | int yq = ( y + histCursor) * columns; | ||
567 | // qDebug("horzCursor %d, columns %d, len %d", horzCursor, columns, len); | ||
568 | // qDebug("lineno %d, colno %d, count %d\n", y + histCursor, (horzCursor / 2), len ); | ||
569 | qDebug("Y %d", y); | ||
570 | hist.getCells( y + histCursor, (horzCursor / 2), len, merged + yp); | ||
571 | |||
572 | for (x = len; x < columns; x++) | ||
573 | merged[yp + x] = dft; | ||
574 | for (x = 0; x < columns; x++) { | ||
575 | int p = x + yp; int q = x + yq; | ||
576 | if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) | ||
577 | reverseRendition(&merged[p]); // for selection | ||
578 | } | ||
579 | } | ||
580 | |||
581 | if (lines >= hist.getLines() - histCursor) { | ||
582 | for (y = ( hist.getLines() - histCursor); y < lines ; y++) { | ||
583 | int z = horzCursor; | ||
584 | int yp = y * columns; | ||
585 | int yq = ( y + histCursor) * columns; | ||
586 | int yr = ( y - hist.getLines() + histCursor) * columns; | ||
587 | // qDebug("y %d, yp %d, yq %d, columns %d, z cursor %d", y, yp, yq, columns, z); | ||
588 | for (x = 0; x < columns; x++) { | ||
589 | int p = x + yp; int q = x + yq; int r = (x + (horzCursor/2) ) + yr; | ||
590 | merged[p] = image[r]; | ||
591 | if ( q >= sel_TL && q <= sel_BR ) | ||
592 | reverseRendition( &merged[p]); // for selection | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | |||
597 | |||
598 | // evtl. inverse display | ||
599 | if (getMode(MODE_Screen)) | ||
600 | { int i, n = lines * columns; | ||
601 | for (i = 0; i < n; i++) | ||
602 | reverseRendition( &merged[i]); // for reverse display | ||
603 | } | ||
604 | if (getMode(MODE_Cursor) && ( cuY + ( hist.getLines() - histCursor) < lines)) // cursor visible | ||
605 | |||
606 | reverseRendition( &merged[ loc( cuX, cuY + ( hist.getLines() - histCursor))] ); | ||
607 | |||
608 | return merged; | ||
609 | */ | ||
610 | |||
611 | } | 553 | } |
612 | 554 | ||
613 | 555 | ||
614 | /*! | 556 | /*! |
615 | */ | 557 | */ |
616 | 558 | ||
617 | void TEScreen::reset() | 559 | void TEScreen::reset() |
618 | { | 560 | { |
619 | Config cfg("Konsole"); | 561 | Config cfg("Konsole"); |
620 | cfg.setGroup("ScrollBar"); | 562 | cfg.setGroup("ScrollBar"); |
621 | if( !cfg.readBoolEntry("HorzScroll",0) ) | 563 | if( !cfg.readBoolEntry("HorzScroll",0) ) |
622 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin | 564 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin |
623 | 565 | ||
624 | 566 | ||
625 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] | 567 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] |
626 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke | 568 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke |
627 | setMode(MODE_Cursor); // cursor visible | 569 | setMode(MODE_Cursor); // cursor visible |
628 | resetMode(MODE_Screen); // screen not inverse | 570 | resetMode(MODE_Screen); // screen not inverse |
629 | resetMode(MODE_NewLine); | 571 | resetMode(MODE_NewLine); |
630 | 572 | ||
631 | tmargin=0; | 573 | tmargin=0; |
632 | bmargin=lines-1; | 574 | bmargin=lines-1; |
633 | 575 | ||
634 | setDefaultRendition(); | 576 | setDefaultRendition(); |
635 | saveCursor(); | 577 | saveCursor(); |
636 | 578 | ||
637 | clear(); | 579 | clear(); |
638 | } | 580 | } |
639 | 581 | ||
640 | /*! Clear the entire screen and home the cursor. | 582 | /*! Clear the entire screen and home the cursor. |
641 | */ | 583 | */ |
642 | 584 | ||
643 | void TEScreen::clear() | 585 | void TEScreen::clear() |
644 | { | 586 | { |
645 | clearEntireScreen(); | 587 | clearEntireScreen(); |
646 | home(); | 588 | home(); |
647 | } | 589 | } |
648 | 590 | ||
649 | /*! Moves the cursor left one column. | 591 | /*! Moves the cursor left one column. |
650 | */ | 592 | */ |
651 | 593 | ||
652 | void TEScreen::BackSpace() | 594 | void TEScreen::BackSpace() |
653 | { | 595 | { |
654 | cuX = QMAX(0,cuX-1); | 596 | cuX = QMAX(0,cuX-1); |
655 | if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; | 597 | if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; |
656 | } | 598 | } |
657 | 599 | ||
658 | /*! | 600 | /*! |
659 | */ | 601 | */ |
660 | 602 | ||
661 | void TEScreen::Tabulate() | 603 | void TEScreen::Tabulate() |
662 | { | 604 | { |
663 | // note that TAB is a format effector (does not write ' '); | 605 | // note that TAB is a format effector (does not write ' '); |
664 | cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); | 606 | cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); |
665 | } | 607 | } |
666 | 608 | ||
667 | void TEScreen::clearTabStops() | 609 | void TEScreen::clearTabStops() |
668 | { | 610 | { |
669 | for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; | 611 | for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; |
670 | } | 612 | } |
671 | 613 | ||
672 | void TEScreen::changeTabStop(bool set) | 614 | void TEScreen::changeTabStop(bool set) |
673 | { | 615 | { |
674 | if (cuX >= columns) return; | 616 | if (cuX >= columns) return; |
675 | tabstops[cuX] = set; | 617 | tabstops[cuX] = set; |
676 | } | 618 | } |
677 | 619 | ||
678 | void TEScreen::initTabStops() | 620 | void TEScreen::initTabStops() |
679 | { | 621 | { |
680 | if (tabstops) free(tabstops); | 622 | if (tabstops) free(tabstops); |
681 | tabstops = (bool*)malloc(columns*sizeof(bool)); | 623 | tabstops = (bool*)malloc(columns*sizeof(bool)); |
682 | // Arrg! The 1st tabstop has to be one longer than the other. | 624 | // Arrg! The 1st tabstop has to be one longer than the other. |
683 | // i.e. the kids start counting from 0 instead of 1. | 625 | // i.e. the kids start counting from 0 instead of 1. |
684 | // Other programs might behave correctly. Be aware. | 626 | // Other programs might behave correctly. Be aware. |
685 | for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); | 627 | for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); |
686 | } | 628 | } |
687 | 629 | ||
688 | /*! | 630 | /*! |
689 | This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) | 631 | This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) |
690 | depending on the NewLine Mode (LNM). This mode also | 632 | depending on the NewLine Mode (LNM). This mode also |
691 | affects the key sequence returned for newline ([CR]LF). | 633 | affects the key sequence returned for newline ([CR]LF). |
692 | */ | 634 | */ |
693 | 635 | ||
694 | void TEScreen::NewLine() | 636 | void TEScreen::NewLine() |
695 | { | 637 | { |
696 | if (getMode(MODE_NewLine)) Return(); | 638 | if (getMode(MODE_NewLine)) Return(); |
697 | index(); | 639 | index(); |
698 | } | 640 | } |
699 | 641 | ||
700 | /*! put `c' literally onto the screen at the current cursor position. | 642 | /*! put `c' literally onto the screen at the current cursor position. |
701 | 643 | ||
702 | VT100 uses the convention to produce an automatic newline (am) | 644 | VT100 uses the convention to produce an automatic newline (am) |
703 | with the *first* character that would fall onto the next line (xenl). | 645 | with the *first* character that would fall onto the next line (xenl). |
704 | */ | 646 | */ |
705 | 647 | ||
706 | void TEScreen::checkSelection(int from, int to) | 648 | void TEScreen::checkSelection(int from, int to) |
707 | { | 649 | { |
708 | if (sel_begin == -1) return; | 650 | if (sel_begin == -1) return; |
709 | int scr_TL = loc(0, hist.getLines()); | 651 | int scr_TL = loc(0, hist.getLines()); |
710 | //Clear entire selection if it overlaps region [from, to] | 652 | //Clear entire selection if it overlaps region [from, to] |
711 | if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) | 653 | if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) |
712 | { | 654 | { |
713 | clearSelection(); | 655 | clearSelection(); |
714 | } | 656 | } |
715 | } | 657 | } |
716 | 658 | ||
717 | void TEScreen::ShowCharacter(unsigned short c) | 659 | void TEScreen::ShowCharacter(unsigned short c) |
718 | { | 660 | { |
719 | // Note that VT100 does wrapping BEFORE putting the character. | 661 | // Note that VT100 does wrapping BEFORE putting the character. |
720 | // This has impact on the assumption of valid cursor positions. | 662 | // This has impact on the assumption of valid cursor positions. |
721 | // We indicate the fact that a newline has to be triggered by | 663 | // We indicate the fact that a newline has to be triggered by |
722 | // putting the cursor one right to the last column of the screen. | 664 | // putting the cursor one right to the last column of the screen. |
723 | 665 | ||
724 | if (cuX >= columns) | 666 | if (cuX >= columns) |
725 | { | 667 | { |
726 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; | 668 | if (getMode(MODE_Wrap)) NextLine(); else cuX = columns - 1; |
727 | // comment out for no wrap | 669 | // comment out for no wrap |
728 | } | 670 | } |
729 | 671 | ||
730 | if (getMode(MODE_Insert)) insertChars(1); | 672 | if (getMode(MODE_Insert)) insertChars(1); |
731 | 673 | ||
732 | int i = loc( cuX, cuY); | 674 | int i = loc( cuX, cuY); |
733 | 675 | ||
734 | checkSelection(i, i); // check if selection is still valid. | 676 | checkSelection(i, i); // check if selection is still valid. |
735 | 677 | ||
736 | image[i].c = c; | 678 | image[i].c = c; |
737 | image[i].f = ef_fg; | 679 | image[i].f = ef_fg; |
738 | image[i].b = ef_bg; | 680 | image[i].b = ef_bg; |
739 | image[i].r = ef_re; | 681 | image[i].r = ef_re; |
740 | 682 | ||
741 | cuX += 1; | 683 | cuX += 1; |
742 | } | 684 | } |
743 | 685 | ||
744 | // Region commands ------------------------------------------------------------- | 686 | // Region commands ------------------------------------------------------------- |
745 | 687 | ||
746 | 688 | ||
747 | /*! scroll up `n' lines within current region. | 689 | /*! scroll up `n' lines within current region. |
748 | The `n' new lines are cleared. | 690 | The `n' new lines are cleared. |
749 | \sa setRegion \sa scrollDown | 691 | \sa setRegion \sa scrollDown |
750 | */ | 692 | */ |
751 | 693 | ||
752 | void TEScreen::scrollUp(int from, int n) | 694 | void TEScreen::scrollUp(int from, int n) |
753 | { | 695 | { |
754 | if (n <= 0 || from + n > bmargin) return; | 696 | if (n <= 0 || from + n > bmargin) return; |
755 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 697 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
756 | 698 | ||
757 | moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); | 699 | moveImage( loc( 0, from), loc( 0, from + n), loc( columns - 1, bmargin)); |
758 | clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); | 700 | clearImage( loc( 0, bmargin - n + 1), loc( columns - 1, bmargin), ' '); |
759 | } | 701 | } |
760 | 702 | ||
761 | /*! scroll down `n' lines within current region. | 703 | /*! scroll down `n' lines within current region. |
762 | The `n' new lines are cleared. | 704 | The `n' new lines are cleared. |
763 | \sa setRegion \sa scrollUp | 705 | \sa setRegion \sa scrollUp |
764 | */ | 706 | */ |
765 | 707 | ||
766 | void TEScreen::scrollDown(int from, int n) | 708 | void TEScreen::scrollDown(int from, int n) |
767 | { | 709 | { |
768 | 710 | ||
769 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. | 711 | //FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds. |
770 | if (n <= 0) return; | 712 | if (n <= 0) return; |
771 | if (from > bmargin) return; | 713 | if (from > bmargin) return; |
772 | if (from + n > bmargin) n = bmargin - from; | 714 | if (from + n > bmargin) n = bmargin - from; |
773 | 715 | ||
774 | moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); | 716 | moveImage( loc(0,from+n), loc(0,from), loc(columns-1,bmargin-n)); |
775 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); | 717 | clearImage(loc(0,from),loc(columns-1,from+n-1),' '); |
776 | } | 718 | } |
777 | 719 | ||
778 | 720 | ||
779 | 721 | ||
780 | /*! position the cursor to a specific line and column. */ | 722 | /*! position the cursor to a specific line and column. */ |
781 | void TEScreen::setCursorYX(int y, int x) | 723 | void TEScreen::setCursorYX(int y, int x) |
782 | { | 724 | { |
783 | setCursorY(y); setCursorX(x); | 725 | setCursorY(y); setCursorX(x); |
784 | } | 726 | } |
785 | 727 | ||
786 | /*! Set the cursor to x-th line. */ | 728 | /*! Set the cursor to x-th line. */ |
787 | 729 | ||
788 | void TEScreen::setCursorX(int x) | 730 | void TEScreen::setCursorX(int x) |
789 | { | 731 | { |
790 | if (x == 0) x = 1; // Default | 732 | if (x == 0) x = 1; // Default |
791 | x -= 1; // Adjust | 733 | x -= 1; // Adjust |
792 | cuX = QMAX(0,QMIN(columns-1, x)); | 734 | cuX = QMAX(0,QMIN(columns-1, x)); |
793 | } | 735 | } |
794 | 736 | ||
795 | /*! Set the cursor to y-th line. */ | 737 | /*! Set the cursor to y-th line. */ |
796 | 738 | ||
797 | void TEScreen::setCursorY(int y) | 739 | void TEScreen::setCursorY(int y) |
798 | { | 740 | { |
799 | if (y == 0) y = 1; // Default | 741 | if (y == 0) y = 1; // Default |
800 | y -= 1; // Adjust | 742 | y -= 1; // Adjust |
801 | cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); | 743 | cuY = QMAX(0,QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) )); |
802 | } | 744 | } |
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 60021f4..d6ee6e8 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -866,541 +866,482 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | |||
866 | x = endSel.x(); | 866 | x = endSel.x(); |
867 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 867 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
868 | { i++; x++ ; } | 868 | { i++; x++ ; } |
869 | endSel.setX(x); | 869 | endSel.setX(x); |
870 | actSel = 2; // within selection | 870 | actSel = 2; // within selection |
871 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 871 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
872 | emit endSelectionSignal(preserve_line_breaks); | 872 | emit endSelectionSignal(preserve_line_breaks); |
873 | preserve_line_breaks = TRUE; | 873 | preserve_line_breaks = TRUE; |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void TEWidget::focusInEvent( QFocusEvent * ) | 877 | void TEWidget::focusInEvent( QFocusEvent * ) |
878 | { | 878 | { |
879 | 879 | ||
880 | // do nothing, to prevent repainting | 880 | // do nothing, to prevent repainting |
881 | } | 881 | } |
882 | 882 | ||
883 | 883 | ||
884 | void TEWidget::focusOutEvent( QFocusEvent * ) | 884 | void TEWidget::focusOutEvent( QFocusEvent * ) |
885 | { | 885 | { |
886 | // do nothing, to prevent repainting | 886 | // do nothing, to prevent repainting |
887 | } | 887 | } |
888 | 888 | ||
889 | bool TEWidget::focusNextPrevChild( bool next ) | 889 | bool TEWidget::focusNextPrevChild( bool next ) |
890 | { | 890 | { |
891 | if (next) | 891 | if (next) |
892 | return false; // This disables changing the active part in konqueror | 892 | return false; // This disables changing the active part in konqueror |
893 | // when pressing Tab | 893 | // when pressing Tab |
894 | return QFrame::focusNextPrevChild( next ); | 894 | return QFrame::focusNextPrevChild( next ); |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | int TEWidget::charClass(char ch) const | 898 | int TEWidget::charClass(char ch) const |
899 | { | 899 | { |
900 | // This might seem like overkill, but imagine if ch was a Unicode | 900 | // This might seem like overkill, but imagine if ch was a Unicode |
901 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 901 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
902 | // the different language ranges, etc. | 902 | // the different language ranges, etc. |
903 | 903 | ||
904 | if ( isspace(ch) ) return ' '; | 904 | if ( isspace(ch) ) return ' '; |
905 | 905 | ||
906 | static const char *word_characters = ":@-./_~"; | 906 | static const char *word_characters = ":@-./_~"; |
907 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 907 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
908 | return 'a'; | 908 | return 'a'; |
909 | 909 | ||
910 | // Everything else is weird | 910 | // Everything else is weird |
911 | return 1; | 911 | return 1; |
912 | } | 912 | } |
913 | 913 | ||
914 | void TEWidget::setMouseMarks(bool on) | 914 | void TEWidget::setMouseMarks(bool on) |
915 | { | 915 | { |
916 | mouse_marks = on; | 916 | mouse_marks = on; |
917 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 917 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
918 | } | 918 | } |
919 | 919 | ||
920 | /* ------------------------------------------------------------------------- */ | 920 | /* ------------------------------------------------------------------------- */ |
921 | /* */ | 921 | /* */ |
922 | /* Clipboard */ | 922 | /* Clipboard */ |
923 | /* */ | 923 | /* */ |
924 | /* ------------------------------------------------------------------------- */ | 924 | /* ------------------------------------------------------------------------- */ |
925 | 925 | ||
926 | #undef KeyPress | 926 | #undef KeyPress |
927 | 927 | ||
928 | void TEWidget::emitSelection() | 928 | void TEWidget::emitSelection() |
929 | // Paste Clipboard by simulating keypress events | 929 | // Paste Clipboard by simulating keypress events |
930 | { | 930 | { |
931 | #ifndef QT_NO_CLIPBOARD | 931 | #ifndef QT_NO_CLIPBOARD |
932 | QString text = QApplication::clipboard()->text(); | 932 | QString text = QApplication::clipboard()->text(); |
933 | if ( ! text.isNull() ) | 933 | if ( ! text.isNull() ) |
934 | { | 934 | { |
935 | text.replace(QRegExp("\n"), "\r"); | 935 | text.replace(QRegExp("\n"), "\r"); |
936 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 936 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
937 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 937 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
938 | emit clearSelectionSignal(); | 938 | emit clearSelectionSignal(); |
939 | } | 939 | } |
940 | #endif | 940 | #endif |
941 | } | 941 | } |
942 | 942 | ||
943 | void TEWidget::emitText(QString text) | 943 | void TEWidget::emitText(QString text) |
944 | { | 944 | { |
945 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 945 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
946 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 946 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
947 | } | 947 | } |
948 | 948 | ||
949 | void TEWidget::pasteClipboard( ) | 949 | void TEWidget::pasteClipboard( ) |
950 | { | 950 | { |
951 | emitSelection(); | 951 | emitSelection(); |
952 | } | 952 | } |
953 | 953 | ||
954 | void TEWidget::setSelection(const QString& t) | 954 | void TEWidget::setSelection(const QString& t) |
955 | { | 955 | { |
956 | #ifndef QT_NO_CLIPBOARD | 956 | #ifndef QT_NO_CLIPBOARD |
957 | // Disconnect signal while WE set the clipboard | 957 | // Disconnect signal while WE set the clipboard |
958 | QObject *cb = QApplication::clipboard(); | 958 | QObject *cb = QApplication::clipboard(); |
959 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 959 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
960 | this, SLOT(onClearSelection()) ); | 960 | this, SLOT(onClearSelection()) ); |
961 | 961 | ||
962 | QApplication::clipboard()->setText(t); | 962 | QApplication::clipboard()->setText(t); |
963 | 963 | ||
964 | QObject::connect( cb, SIGNAL(dataChanged()), | 964 | QObject::connect( cb, SIGNAL(dataChanged()), |
965 | this, SLOT(onClearSelection()) ); | 965 | this, SLOT(onClearSelection()) ); |
966 | #endif | 966 | #endif |
967 | } | 967 | } |
968 | 968 | ||
969 | void TEWidget::onClearSelection() | 969 | void TEWidget::onClearSelection() |
970 | { | 970 | { |
971 | emit clearSelectionSignal(); | 971 | emit clearSelectionSignal(); |
972 | } | 972 | } |
973 | 973 | ||
974 | /* ------------------------------------------------------------------------- */ | 974 | /* ------------------------------------------------------------------------- */ |
975 | /* */ | 975 | /* */ |
976 | /* Keyboard */ | 976 | /* Keyboard */ |
977 | /* */ | 977 | /* */ |
978 | /* ------------------------------------------------------------------------- */ | 978 | /* ------------------------------------------------------------------------- */ |
979 | 979 | ||
980 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 980 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
981 | // due to a bug in `QT' or the ignorance of the author to prevent | 981 | // due to a bug in `QT' or the ignorance of the author to prevent |
982 | // repaint events being emitted to the screen whenever one leaves | 982 | // repaint events being emitted to the screen whenever one leaves |
983 | // or reenters the screen to/from another application. | 983 | // or reenters the screen to/from another application. |
984 | // | 984 | // |
985 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 985 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
986 | // which would also let you have an in-focus cursor and an out-focus | 986 | // which would also let you have an in-focus cursor and an out-focus |
987 | // cursor like xterm does. | 987 | // cursor like xterm does. |
988 | 988 | ||
989 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 989 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
990 | // focusOutEvent() so that update() isn't called. | 990 | // focusOutEvent() so that update() isn't called. |
991 | // For auto-hide, we need to get keypress-events, but we only get them when | 991 | // For auto-hide, we need to get keypress-events, but we only get them when |
992 | // we have focus. | 992 | // we have focus. |
993 | 993 | ||
994 | void TEWidget::doScroll(int lines) | 994 | void TEWidget::doScroll(int lines) |
995 | { | 995 | { |
996 | scrollbar->setValue(scrollbar->value()+lines); | 996 | scrollbar->setValue(scrollbar->value()+lines); |
997 | } | 997 | } |
998 | 998 | ||
999 | void TEWidget::doHScroll(int lines) { | 999 | void TEWidget::doHScroll(int lines) { |
1000 | hScrollbar->setValue( hScrollbar->value()+lines); | 1000 | hScrollbar->setValue( hScrollbar->value()+lines); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1003 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
1004 | { | 1004 | { |
1005 | if ( (e->type() == QEvent::Accel || | 1005 | if ( (e->type() == QEvent::Accel || |
1006 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1006 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1007 | static_cast<QKeyEvent *>( e )->ignore(); | 1007 | static_cast<QKeyEvent *>( e )->ignore(); |
1008 | return true; | 1008 | return true; |
1009 | } | 1009 | } |
1010 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1010 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1011 | return FALSE; // not us | 1011 | return FALSE; // not us |
1012 | if ( e->type() == QEvent::Wheel) { | 1012 | if ( e->type() == QEvent::Wheel) { |
1013 | QApplication::sendEvent(scrollbar, e); | 1013 | QApplication::sendEvent(scrollbar, e); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | #ifdef FAKE_CTRL_AND_ALT | 1016 | #ifdef FAKE_CTRL_AND_ALT |
1017 | static bool control = FALSE; | 1017 | static bool control = FALSE; |
1018 | static bool alt = FALSE; | 1018 | static bool alt = FALSE; |
1019 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1019 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1020 | bool dele=FALSE; | 1020 | bool dele=FALSE; |
1021 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1021 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1022 | QKeyEvent* ke = (QKeyEvent*)e; | 1022 | QKeyEvent* ke = (QKeyEvent*)e; |
1023 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1023 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1024 | switch (ke->key()) { | 1024 | switch (ke->key()) { |
1025 | case Key_F9: // let this be "Control" | 1025 | case Key_F9: // let this be "Control" |
1026 | control = keydown; | 1026 | control = keydown; |
1027 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1027 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1028 | dele=TRUE; | 1028 | dele=TRUE; |
1029 | break; | 1029 | break; |
1030 | case Key_F13: // let this be "Alt" | 1030 | case Key_F13: // let this be "Alt" |
1031 | alt = keydown; | 1031 | alt = keydown; |
1032 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1032 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1033 | dele=TRUE; | 1033 | dele=TRUE; |
1034 | break; | 1034 | break; |
1035 | default: | 1035 | default: |
1036 | if ( control ) { | 1036 | if ( control ) { |
1037 | int a = toupper(ke->ascii())-64; | 1037 | int a = toupper(ke->ascii())-64; |
1038 | if ( a >= 0 && a < ' ' ) { | 1038 | if ( a >= 0 && a < ' ' ) { |
1039 | e = new QKeyEvent(e->type(), ke->key(), | 1039 | e = new QKeyEvent(e->type(), ke->key(), |
1040 | a, ke->state()|ControlButton, QChar(a,0)); | 1040 | a, ke->state()|ControlButton, QChar(a,0)); |
1041 | dele=TRUE; | 1041 | dele=TRUE; |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | if ( alt ) { | 1044 | if ( alt ) { |
1045 | e = new QKeyEvent(e->type(), ke->key(), | 1045 | e = new QKeyEvent(e->type(), ke->key(), |
1046 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1046 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1047 | dele=TRUE; | 1047 | dele=TRUE; |
1048 | } | 1048 | } |
1049 | } | 1049 | } |
1050 | } | 1050 | } |
1051 | #endif | 1051 | #endif |
1052 | 1052 | ||
1053 | if ( e->type() == QEvent::KeyPress ) { | 1053 | if ( e->type() == QEvent::KeyPress ) { |
1054 | QKeyEvent* ke = (QKeyEvent*)e; | 1054 | QKeyEvent* ke = (QKeyEvent*)e; |
1055 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1055 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1056 | // know where the current selection is. | 1056 | // know where the current selection is. |
1057 | 1057 | ||
1058 | // qDebug("key pressed is 0x%x, state %d",ke->key(), ke->state()); | 1058 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); |
1059 | 1059 | ||
1060 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1060 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { |
1061 | //lets hardcode this sucker | 1061 | //lets hardcode this sucker |
1062 | 1062 | ||
1063 | // qDebug("key pressed 2 is 0x%x",ke->key()); | 1063 | // qDebug("key pressed 2 is 0x%x", ke->key()); |
1064 | emitText("\\"); // expose | 1064 | emitText("\\"); // expose |
1065 | } | 1065 | } |
1066 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1066 | else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1067 | pasteClipboard(); | 1067 | pasteClipboard(); |
1068 | } | 1068 | } |
1069 | else | 1069 | else |
1070 | emit keyPressedSignal(ke); // expose | 1070 | emit keyPressedSignal(ke); // expose |
1071 | ke->accept(); | 1071 | ke->accept(); |
1072 | #ifdef FAKE_CTRL_AND_ALT | 1072 | #ifdef FAKE_CTRL_AND_ALT |
1073 | if ( dele ) delete e; | 1073 | if ( dele ) delete e; |
1074 | #endif | 1074 | #endif |
1075 | return true; // stop the event | 1075 | return true; // stop the event |
1076 | } | 1076 | } |
1077 | if ( e->type() == QEvent::Enter ) { | 1077 | if ( e->type() == QEvent::Enter ) { |
1078 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1078 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1079 | this, SLOT(onClearSelection()) ); | 1079 | this, SLOT(onClearSelection()) ); |
1080 | } | 1080 | } |
1081 | if ( e->type() == QEvent::Leave ) { | 1081 | if ( e->type() == QEvent::Leave ) { |
1082 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1082 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1083 | this, SLOT(onClearSelection()) ); | 1083 | this, SLOT(onClearSelection()) ); |
1084 | } | 1084 | } |
1085 | return QFrame::eventFilter( obj, e ); | 1085 | return QFrame::eventFilter( obj, e ); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | /* ------------------------------------------------------------------------- */ | 1088 | /* ------------------------------------------------------------------------- */ |
1089 | /* */ | 1089 | /* */ |
1090 | /* Frame */ | 1090 | /* Frame */ |
1091 | /* */ | 1091 | /* */ |
1092 | /* ------------------------------------------------------------------------- */ | 1092 | /* ------------------------------------------------------------------------- */ |
1093 | 1093 | ||
1094 | void TEWidget::frameChanged() | 1094 | void TEWidget::frameChanged() |
1095 | { | 1095 | { |
1096 | propagateSize(); | 1096 | propagateSize(); |
1097 | update(); | 1097 | update(); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | /* ------------------------------------------------------------------------- */ | 1100 | /* ------------------------------------------------------------------------- */ |
1101 | /* */ | 1101 | /* */ |
1102 | /* Sound */ | 1102 | /* Sound */ |
1103 | /* */ | 1103 | /* */ |
1104 | /* ------------------------------------------------------------------------- */ | 1104 | /* ------------------------------------------------------------------------- */ |
1105 | 1105 | ||
1106 | void TEWidget::Bell() | 1106 | void TEWidget::Bell() |
1107 | { | 1107 | { |
1108 | //#ifdef QT_QWS_CUSTOM | 1108 | //#ifdef QT_QWS_CUSTOM |
1109 | //# ifndef QT_NO_COP | 1109 | //# ifndef QT_NO_COP |
1110 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1110 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); |
1111 | //# endif | 1111 | //# endif |
1112 | //#else | 1112 | //#else |
1113 | //# ifndef QT_NO_SOUND | 1113 | //# ifndef QT_NO_SOUND |
1114 | // QSound::play(Resource::findSound("alarm")); | 1114 | // QSound::play(Resource::findSound("alarm")); |
1115 | //# endif | 1115 | //# endif |
1116 | //#endif | 1116 | //#endif |
1117 | 1117 | ||
1118 | // QApplication::beep(); | 1118 | // QApplication::beep(); |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | /* ------------------------------------------------------------------------- */ | 1121 | /* ------------------------------------------------------------------------- */ |
1122 | /* */ | 1122 | /* */ |
1123 | /* Auxiluary */ | 1123 | /* Auxiluary */ |
1124 | /* */ | 1124 | /* */ |
1125 | /* ------------------------------------------------------------------------- */ | 1125 | /* ------------------------------------------------------------------------- */ |
1126 | 1126 | ||
1127 | void TEWidget::clearImage() | 1127 | void TEWidget::clearImage() |
1128 | // initialize the image | 1128 | // initialize the image |
1129 | // for internal use only | 1129 | // for internal use only |
1130 | { | 1130 | { |
1131 | for (int y = 0; y < lines; y++) | 1131 | for (int y = 0; y < lines; y++) |
1132 | for (int x = 0; x < columns; x++) | 1132 | for (int x = 0; x < columns; x++) |
1133 | { | 1133 | { |
1134 | image[loc(x,y)].c = 0xff; //' '; | 1134 | image[loc(x,y)].c = 0xff; //' '; |
1135 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1135 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1136 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1136 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1137 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1137 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | // Create Image /////////////////////////////////////////////////////// | 1141 | // Create Image /////////////////////////////////////////////////////// |
1142 | 1142 | ||
1143 | void TEWidget::calcGeometry() | 1143 | void TEWidget::calcGeometry() |
1144 | { | 1144 | { |
1145 | int showhscrollbar = 1; | 1145 | int showhscrollbar = 1; |
1146 | int hwidth = 0; | 1146 | int hwidth = 0; |
1147 | int dcolumns; | 1147 | int dcolumns; |
1148 | Config cfg("Konsole"); | 1148 | Config cfg("Konsole"); |
1149 | cfg.setGroup("ScrollBar"); | 1149 | cfg.setGroup("ScrollBar"); |
1150 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1150 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1151 | 1151 | ||
1152 | if(vcolumns == 0) showhscrollbar = 0; | 1152 | if(vcolumns == 0) showhscrollbar = 0; |
1153 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1153 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1154 | 1154 | ||
1155 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1155 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1156 | contentsRect().height() - hwidth); | 1156 | contentsRect().height() - hwidth); |
1157 | 1157 | ||
1158 | switch(scrollLoc) { | 1158 | switch(scrollLoc) { |
1159 | case SCRNONE : | 1159 | case SCRNONE : |
1160 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1160 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1161 | dcolumns = columns; | 1161 | dcolumns = columns; |
1162 | if(vcolumns) columns = vcolumns; | 1162 | if(vcolumns) columns = vcolumns; |
1163 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1163 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1164 | if(showhscrollbar) | 1164 | if(showhscrollbar) |
1165 | blX = -hposition * font_w; | 1165 | blX = -hposition * font_w; |
1166 | brX = blX; | 1166 | brX = blX; |
1167 | scrollbar->hide(); | 1167 | scrollbar->hide(); |
1168 | break; | 1168 | break; |
1169 | case SCRLEFT : | 1169 | case SCRLEFT : |
1170 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1170 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1171 | dcolumns = columns; | 1171 | dcolumns = columns; |
1172 | if(vcolumns) columns = vcolumns; | 1172 | if(vcolumns) columns = vcolumns; |
1173 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1173 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1174 | if(showhscrollbar) | 1174 | if(showhscrollbar) |
1175 | brX = -hposition * font_w; | 1175 | brX = -hposition * font_w; |
1176 | blX = brX + scrollbar->width(); | 1176 | blX = brX + scrollbar->width(); |
1177 | scrollbar->move(contentsRect().topLeft()); | 1177 | scrollbar->move(contentsRect().topLeft()); |
1178 | scrollbar->show(); | 1178 | scrollbar->show(); |
1179 | break; | 1179 | break; |
1180 | case SCRRIGHT: | 1180 | case SCRRIGHT: |
1181 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1181 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1182 | dcolumns = columns; | 1182 | dcolumns = columns; |
1183 | if(vcolumns) columns = vcolumns; | 1183 | if(vcolumns) columns = vcolumns; |
1184 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1184 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1185 | if(showhscrollbar) | 1185 | if(showhscrollbar) |
1186 | blX = -hposition * font_w; | 1186 | blX = -hposition * font_w; |
1187 | brX = blX; | 1187 | brX = blX; |
1188 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1188 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1189 | scrollbar->show(); | 1189 | scrollbar->show(); |
1190 | break; | 1190 | break; |
1191 | } | 1191 | } |
1192 | //FIXME: support 'rounding' styles | 1192 | //FIXME: support 'rounding' styles |
1193 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1193 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1194 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1194 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1195 | 1195 | ||
1196 | if(showhscrollbar == 1) { | 1196 | if(showhscrollbar == 1) { |
1197 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1197 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1198 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1198 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1199 | 1199 | ||
1200 | QPoint p = contentsRect().bottomLeft(); | 1200 | QPoint p = contentsRect().bottomLeft(); |
1201 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1201 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1202 | hScrollbar->show(); | 1202 | hScrollbar->show(); |
1203 | } | 1203 | } |
1204 | else hScrollbar->hide(); | 1204 | else hScrollbar->hide(); |
1205 | 1205 | ||
1206 | if(showhscrollbar == 1) { | 1206 | if(showhscrollbar == 1) { |
1207 | lines = lines - (hwidth / font_h) - 1; | 1207 | lines = lines - (hwidth / font_h) - 1; |
1208 | if(lines < 1) lines = 1; | 1208 | if(lines < 1) lines = 1; |
1209 | } | 1209 | } |
1210 | |||
1211 | /*//FIXME: set rimX == rimY == 0 when running in full screen mode. | ||
1212 | Config cfg("Konsole"); | ||
1213 | cfg.setGroup("ScrollBar"); | ||
1214 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | ||
1215 | |||
1216 | scrollbar->resize( QApplication::style().scrollBarExtent().width(), | ||
1217 | contentsRect().height()); | ||
1218 | qDebug("font_w %d", font_w); | ||
1219 | switch(scrollLoc) | ||
1220 | { | ||
1221 | case SCRNONE : | ||
1222 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | ||
1223 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | ||
1224 | brX = blX; | ||
1225 | scrollbar->hide(); | ||
1226 | break; | ||
1227 | case SCRLEFT : | ||
1228 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1229 | if(useHorzScroll) columns = columns * (font_w/2); | ||
1230 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1231 | blX = brX + scrollbar->width(); | ||
1232 | scrollbar->move(contentsRect().topLeft()); | ||
1233 | scrollbar->show(); | ||
1234 | break; | ||
1235 | case SCRRIGHT: | ||
1236 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width() ) / font_w; | ||
1237 | if(useHorzScroll) columns = columns * (font_w/2); | ||
1238 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1239 | if(useHorzScroll) { | ||
1240 | brX = blX =2; | ||
1241 | } else { | ||
1242 | brX=blX; | ||
1243 | } | ||
1244 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0) ); | ||
1245 | scrollbar->show(); | ||
1246 | break; | ||
1247 | } | ||
1248 | |||
1249 | if( !scrollbar->isHidden()) | ||
1250 | hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style() | ||
1251 | .scrollBarExtent().height()); | ||
1252 | else | ||
1253 | hScrollbar->resize( contentsRect().width(), QApplication::style() | ||
1254 | .scrollBarExtent().height()); | ||
1255 | |||
1256 | hScrollbar->move( 0, contentsRect().height() - SCRWIDTH); | ||
1257 | |||
1258 | |||
1259 | if(useHorzScroll) { | ||
1260 | hScrollbar->show(); | ||
1261 | lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h; | ||
1262 | bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2; | ||
1263 | } else { | ||
1264 | hScrollbar->hide(); | ||
1265 | lines = (contentsRect().height() - 2 * rimY ) / font_h; | ||
1266 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1267 | } | ||
1268 | */ | ||
1269 | //FIXME: support 'rounding' styles | 1210 | //FIXME: support 'rounding' styles |
1270 | } | 1211 | } |
1271 | 1212 | ||
1272 | void TEWidget::makeImage() | 1213 | void TEWidget::makeImage() |
1273 | //FIXME: rename 'calcGeometry? | 1214 | //FIXME: rename 'calcGeometry? |
1274 | { | 1215 | { |
1275 | calcGeometry(); | 1216 | calcGeometry(); |
1276 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1217 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1277 | clearImage(); | 1218 | clearImage(); |
1278 | } | 1219 | } |
1279 | 1220 | ||
1280 | // calculate the needed size | 1221 | // calculate the needed size |
1281 | QSize TEWidget::calcSize(int cols, int lins) const | 1222 | QSize TEWidget::calcSize(int cols, int lins) const |
1282 | { | 1223 | { |
1283 | int frw = width() - contentsRect().width(); | 1224 | int frw = width() - contentsRect().width(); |
1284 | int frh = height() - contentsRect().height(); | 1225 | int frh = height() - contentsRect().height(); |
1285 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1226 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1286 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1227 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1287 | } | 1228 | } |
1288 | 1229 | ||
1289 | QSize TEWidget::sizeHint() const | 1230 | QSize TEWidget::sizeHint() const |
1290 | { | 1231 | { |
1291 | return size(); | 1232 | return size(); |
1292 | } | 1233 | } |
1293 | 1234 | ||
1294 | void TEWidget::styleChange(QStyle &) | 1235 | void TEWidget::styleChange(QStyle &) |
1295 | { | 1236 | { |
1296 | propagateSize(); | 1237 | propagateSize(); |
1297 | } | 1238 | } |
1298 | 1239 | ||
1299 | #ifndef QT_NO_DRAGANDDROP | 1240 | #ifndef QT_NO_DRAGANDDROP |
1300 | 1241 | ||
1301 | /* --------------------------------------------------------------------- */ | 1242 | /* --------------------------------------------------------------------- */ |
1302 | /* */ | 1243 | /* */ |
1303 | /* Drag & Drop */ | 1244 | /* Drag & Drop */ |
1304 | /* */ | 1245 | /* */ |
1305 | /* --------------------------------------------------------------------- */ | 1246 | /* --------------------------------------------------------------------- */ |
1306 | 1247 | ||
1307 | 1248 | ||
1308 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1249 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1309 | { | 1250 | { |
1310 | e->accept(QTextDrag::canDecode(e) || | 1251 | e->accept(QTextDrag::canDecode(e) || |
1311 | QUriDrag::canDecode(e)); | 1252 | QUriDrag::canDecode(e)); |
1312 | } | 1253 | } |
1313 | 1254 | ||
1314 | void TEWidget::dropEvent(QDropEvent* event) | 1255 | void TEWidget::dropEvent(QDropEvent* event) |
1315 | { | 1256 | { |
1316 | // The current behaviour when url(s) are dropped is | 1257 | // The current behaviour when url(s) are dropped is |
1317 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1258 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1318 | // * in all other cases, just paste | 1259 | // * in all other cases, just paste |
1319 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1260 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1320 | QStrList strlist; | 1261 | QStrList strlist; |
1321 | int file_count = 0; | 1262 | int file_count = 0; |
1322 | dropText = ""; | 1263 | dropText = ""; |
1323 | bool bPopup = true; | 1264 | bool bPopup = true; |
1324 | 1265 | ||
1325 | if(QUriDrag::decode(event, strlist)) { | 1266 | if(QUriDrag::decode(event, strlist)) { |
1326 | if (strlist.count()) { | 1267 | if (strlist.count()) { |
1327 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1268 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1328 | if(file_count++ > 0) { | 1269 | if(file_count++ > 0) { |
1329 | dropText += " "; | 1270 | dropText += " "; |
1330 | bPopup = false; // more than one file, don't popup | 1271 | bPopup = false; // more than one file, don't popup |
1331 | } | 1272 | } |
1332 | 1273 | ||
1333 | /* | 1274 | /* |
1334 | KURL url(p); | 1275 | KURL url(p); |
1335 | if (url.isLocalFile()) { | 1276 | if (url.isLocalFile()) { |
1336 | dropText += url.path(); // local URL : remove protocol | 1277 | dropText += url.path(); // local URL : remove protocol |
1337 | } | 1278 | } |
1338 | else { | 1279 | else { |
1339 | dropText += url.prettyURL(); | 1280 | dropText += url.prettyURL(); |
1340 | bPopup = false; // a non-local file, don't popup | 1281 | bPopup = false; // a non-local file, don't popup |
1341 | } | 1282 | } |
1342 | */ | 1283 | */ |
1343 | 1284 | ||
1344 | } | 1285 | } |
1345 | 1286 | ||
1346 | if (bPopup) | 1287 | if (bPopup) |
1347 | // m_drop->popup(pos() + event->pos()); | 1288 | // m_drop->popup(pos() + event->pos()); |
1348 | m_drop->popup(mapToGlobal(event->pos())); | 1289 | m_drop->popup(mapToGlobal(event->pos())); |
1349 | else | 1290 | else |
1350 | { | 1291 | { |
1351 | if (currentSession) { | 1292 | if (currentSession) { |
1352 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1293 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1353 | } | 1294 | } |
1354 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1295 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1355 | } | 1296 | } |
1356 | } | 1297 | } |
1357 | } | 1298 | } |
1358 | else if(QTextDrag::decode(event, dropText)) { | 1299 | else if(QTextDrag::decode(event, dropText)) { |
1359 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1300 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1360 | if (currentSession) { | 1301 | if (currentSession) { |
1361 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1302 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1362 | } | 1303 | } |
1363 | // Paste it | 1304 | // Paste it |
1364 | } | 1305 | } |
1365 | } | 1306 | } |
1366 | #endif | 1307 | #endif |
1367 | 1308 | ||
1368 | 1309 | ||
1369 | void TEWidget::drop_menu_activated(int item) | 1310 | void TEWidget::drop_menu_activated(int item) |
1370 | { | 1311 | { |
1371 | #ifndef QT_NO_DRAGANDDROP | 1312 | #ifndef QT_NO_DRAGANDDROP |
1372 | switch (item) | 1313 | switch (item) |
1373 | { | 1314 | { |
1374 | case 0: // paste | 1315 | case 0: // paste |
1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1316 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1376 | // KWM::activate((Window)this->winId()); | 1317 | // KWM::activate((Window)this->winId()); |
1377 | break; | 1318 | break; |
1378 | case 1: // cd ... | 1319 | case 1: // cd ... |
1379 | currentSession->getEmulation()->sendString("cd "); | 1320 | currentSession->getEmulation()->sendString("cd "); |
1380 | struct stat statbuf; | 1321 | struct stat statbuf; |
1381 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1322 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1382 | { | 1323 | { |
1383 | if ( !S_ISDIR(statbuf.st_mode) ) | 1324 | if ( !S_ISDIR(statbuf.st_mode) ) |
1384 | { | 1325 | { |
1385 | /* | 1326 | /* |
1386 | KURL url; | 1327 | KURL url; |
1387 | url.setPath( dropText ); | 1328 | url.setPath( dropText ); |
1388 | dropText = url.directory( true, false ); // remove filename | 1329 | dropText = url.directory( true, false ); // remove filename |
1389 | */ | 1330 | */ |
1390 | } | 1331 | } |
1391 | } | 1332 | } |
1392 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1333 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1393 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1334 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1394 | currentSession->getEmulation()->sendString("\n"); | 1335 | currentSession->getEmulation()->sendString("\n"); |
1395 | // KWM::activate((Window)this->winId()); | 1336 | // KWM::activate((Window)this->winId()); |
1396 | break; | 1337 | break; |
1397 | } | 1338 | } |
1398 | #endif | 1339 | #endif |
1399 | } | 1340 | } |
1400 | 1341 | ||
1401 | void TEWidget::setWrapAt(int columns) | 1342 | void TEWidget::setWrapAt(int columns) |
1402 | { | 1343 | { |
1403 | vcolumns = columns; | 1344 | vcolumns = columns; |
1404 | propagateSize(); | 1345 | propagateSize(); |
1405 | update(); | 1346 | update(); |
1406 | } | 1347 | } |