author | drw <drw> | 2004-04-06 15:52:02 (UTC) |
---|---|---|
committer | drw <drw> | 2004-04-06 15:52:02 (UTC) |
commit | 31a82304d62ab4943c0926c35cce552e2164eaf4 (patch) (unidiff) | |
tree | 9c87a50ef57475a765dc16c26100372026dbdda2 | |
parent | e97648cdac8aba383e69e87c2d60644eb3bcc18d (diff) | |
download | opie-31a82304d62ab4943c0926c35cce552e2164eaf4.zip opie-31a82304d62ab4943c0926c35cce552e2164eaf4.tar.gz opie-31a82304d62ab4943c0926c35cce552e2164eaf4.tar.bz2 |
Do not override menu font size, use font as defined in Appearance settings, and fixed compiler warning
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 9 |
2 files changed, 2 insertions, 11 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index cc88555..93348f4 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -556,513 +556,513 @@ void TEWidget::blinkEvent() | |||
556 | /* */ | 556 | /* */ |
557 | /* ------------------------------------------------------------------------- */ | 557 | /* ------------------------------------------------------------------------- */ |
558 | 558 | ||
559 | void TEWidget::resizeEvent(QResizeEvent* ev) | 559 | void TEWidget::resizeEvent(QResizeEvent* ev) |
560 | { | 560 | { |
561 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | 561 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); |
562 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | 562 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); |
563 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | 563 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); |
564 | //printf("curren: %d,%d\n",width(),height()); | 564 | //printf("curren: %d,%d\n",width(),height()); |
565 | HCNT("resizeEvent"); | 565 | HCNT("resizeEvent"); |
566 | 566 | ||
567 | // see comment in `paintEvent' concerning the rounding. | 567 | // see comment in `paintEvent' concerning the rounding. |
568 | //FIXME: could make a routine here; check width(),height() | 568 | //FIXME: could make a routine here; check width(),height() |
569 | assert(ev->size().width() == width()); | 569 | assert(ev->size().width() == width()); |
570 | assert(ev->size().height() == height()); | 570 | assert(ev->size().height() == height()); |
571 | 571 | ||
572 | propagateSize(); | 572 | propagateSize(); |
573 | } | 573 | } |
574 | 574 | ||
575 | void TEWidget::propagateSize() | 575 | void TEWidget::propagateSize() |
576 | { | 576 | { |
577 | ca* oldimg = image; | 577 | ca* oldimg = image; |
578 | int oldlin = lines; | 578 | int oldlin = lines; |
579 | int oldcol = columns; | 579 | int oldcol = columns; |
580 | makeImage(); | 580 | makeImage(); |
581 | // we copy the old image to reduce flicker | 581 | // we copy the old image to reduce flicker |
582 | int lins = QMIN(oldlin,lines); | 582 | int lins = QMIN(oldlin,lines); |
583 | int cols = QMIN(oldcol,columns); | 583 | int cols = QMIN(oldcol,columns); |
584 | if (oldimg) | 584 | if (oldimg) |
585 | { | 585 | { |
586 | for (int lin = 0; lin < lins; lin++) | 586 | for (int lin = 0; lin < lins; lin++) |
587 | memcpy((void*)&image[columns*lin], | 587 | memcpy((void*)&image[columns*lin], |
588 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); | 588 | (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); |
589 | free(oldimg); //FIXME: try new,delete | 589 | free(oldimg); //FIXME: try new,delete |
590 | } | 590 | } |
591 | else | 591 | else |
592 | clearImage(); | 592 | clearImage(); |
593 | 593 | ||
594 | //NOTE: control flows from the back through the chest right into the eye. | 594 | //NOTE: control flows from the back through the chest right into the eye. |
595 | // `emu' will call back via `setImage'. | 595 | // `emu' will call back via `setImage'. |
596 | 596 | ||
597 | resizing = TRUE; | 597 | resizing = TRUE; |
598 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | 598 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent |
599 | resizing = FALSE; | 599 | resizing = FALSE; |
600 | } | 600 | } |
601 | 601 | ||
602 | /* ------------------------------------------------------------------------- */ | 602 | /* ------------------------------------------------------------------------- */ |
603 | /* */ | 603 | /* */ |
604 | /* Scrollbar */ | 604 | /* Scrollbar */ |
605 | /* */ | 605 | /* */ |
606 | /* ------------------------------------------------------------------------- */ | 606 | /* ------------------------------------------------------------------------- */ |
607 | 607 | ||
608 | void TEWidget::scrollChanged(int) { | 608 | void TEWidget::scrollChanged(int) { |
609 | emit changedHistoryCursor(scrollbar->value()); //expose | 609 | emit changedHistoryCursor(scrollbar->value()); //expose |
610 | } | 610 | } |
611 | 611 | ||
612 | void TEWidget::hScrollChanged(int loc) { | 612 | void TEWidget::hScrollChanged(int loc) { |
613 | hposition = loc; | 613 | hposition = loc; |
614 | propagateSize(); | 614 | propagateSize(); |
615 | update(); | 615 | update(); |
616 | 616 | ||
617 | // emit changedHorzCursor( hScrollbar->value()); //expose | 617 | // emit changedHorzCursor( hScrollbar->value()); //expose |
618 | } | 618 | } |
619 | 619 | ||
620 | void TEWidget::setScroll(int cursor, int slines) | 620 | void TEWidget::setScroll(int cursor, int slines) |
621 | { | 621 | { |
622 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 622 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
623 | scrollbar->setRange(0,slines); | 623 | scrollbar->setRange(0,slines); |
624 | scrollbar->setSteps(1,lines); | 624 | scrollbar->setSteps(1,lines); |
625 | scrollbar->setValue(cursor); | 625 | scrollbar->setValue(cursor); |
626 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 626 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
627 | } | 627 | } |
628 | 628 | ||
629 | void TEWidget::setScrollbarLocation(int loc) | 629 | void TEWidget::setScrollbarLocation(int loc) |
630 | { | 630 | { |
631 | if (scrollLoc == loc) return; // quickly | 631 | if (scrollLoc == loc) return; // quickly |
632 | scrollLoc = loc; | 632 | scrollLoc = loc; |
633 | propagateSize(); | 633 | propagateSize(); |
634 | update(); | 634 | update(); |
635 | } | 635 | } |
636 | 636 | ||
637 | /* ------------------------------------------------------------------------- */ | 637 | /* ------------------------------------------------------------------------- */ |
638 | /* */ | 638 | /* */ |
639 | /* Mouse */ | 639 | /* Mouse */ |
640 | /* */ | 640 | /* */ |
641 | /* ------------------------------------------------------------------------- */ | 641 | /* ------------------------------------------------------------------------- */ |
642 | 642 | ||
643 | /*! | 643 | /*! |
644 | Three different operations can be performed using the mouse, and the | 644 | Three different operations can be performed using the mouse, and the |
645 | routines in this section serve all of them: | 645 | routines in this section serve all of them: |
646 | 646 | ||
647 | 1) The press/release events are exposed to the application | 647 | 1) The press/release events are exposed to the application |
648 | 2) Marking (press and move left button) and Pasting (press middle button) | 648 | 2) Marking (press and move left button) and Pasting (press middle button) |
649 | 3) The right mouse button is used from the configuration menu | 649 | 3) The right mouse button is used from the configuration menu |
650 | 650 | ||
651 | NOTE: During the marking process we attempt to keep the cursor within | 651 | NOTE: During the marking process we attempt to keep the cursor within |
652 | the bounds of the text as being displayed by setting the mouse position | 652 | the bounds of the text as being displayed by setting the mouse position |
653 | whenever the mouse has left the text area. | 653 | whenever the mouse has left the text area. |
654 | 654 | ||
655 | Two reasons to do so: | 655 | Two reasons to do so: |
656 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 656 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
657 | Thus a `XGrapPointer' would have to be used instead. | 657 | Thus a `XGrapPointer' would have to be used instead. |
658 | 2) Even if so, this would not help too much, since the text area | 658 | 2) Even if so, this would not help too much, since the text area |
659 | of the TEWidget is normally not identical with it's bounds. | 659 | of the TEWidget is normally not identical with it's bounds. |
660 | 660 | ||
661 | The disadvantage of the current handling is, that the mouse can visibly | 661 | The disadvantage of the current handling is, that the mouse can visibly |
662 | leave the bounds of the widget and is then moved back. Because of the | 662 | leave the bounds of the widget and is then moved back. Because of the |
663 | current construction, and the reasons mentioned above, we cannot do better | 663 | current construction, and the reasons mentioned above, we cannot do better |
664 | without changing the overall construction. | 664 | without changing the overall construction. |
665 | */ | 665 | */ |
666 | 666 | ||
667 | /*! | 667 | /*! |
668 | */ | 668 | */ |
669 | 669 | ||
670 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 670 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
671 | { | 671 | { |
672 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 672 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
673 | if ( !contentsRect().contains(ev->pos()) ) return; | 673 | if ( !contentsRect().contains(ev->pos()) ) return; |
674 | QPoint tL = contentsRect().topLeft(); | 674 | QPoint tL = contentsRect().topLeft(); |
675 | int tLx = tL.x(); | 675 | int tLx = tL.x(); |
676 | int tLy = tL.y(); | 676 | int tLy = tL.y(); |
677 | 677 | ||
678 | mouse_down_x = ev->x(); | 678 | mouse_down_x = ev->x(); |
679 | mouse_down_y = ev->y(); | 679 | mouse_down_y = ev->y(); |
680 | 680 | ||
681 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 681 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
682 | if ( ev->button() == LeftButton) | 682 | if ( ev->button() == LeftButton) |
683 | { | 683 | { |
684 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 684 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
685 | 685 | ||
686 | word_selection_mode = (ev->state() & ShiftButton); | 686 | word_selection_mode = (ev->state() & ShiftButton); |
687 | 687 | ||
688 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 688 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
689 | 689 | ||
690 | if (mouse_marks || (ev->state() & ShiftButton)) | 690 | if (mouse_marks || (ev->state() & ShiftButton)) |
691 | { | 691 | { |
692 | emit clearSelectionSignal(); | 692 | emit clearSelectionSignal(); |
693 | iPntSel = pntSel = pos; | 693 | iPntSel = pntSel = pos; |
694 | actSel = 1; // left mouse button pressed but nothing selected yet. | 694 | actSel = 1; // left mouse button pressed but nothing selected yet. |
695 | grabMouse( /*crossCursor*/ ); // handle with care! | 695 | grabMouse( /*crossCursor*/ ); // handle with care! |
696 | } | 696 | } |
697 | else | 697 | else |
698 | { | 698 | { |
699 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 699 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
700 | } | 700 | } |
701 | } | 701 | } |
702 | if ( ev->button() == MidButton ) | 702 | if ( ev->button() == MidButton ) |
703 | { | 703 | { |
704 | emitSelection(); | 704 | emitSelection(); |
705 | } | 705 | } |
706 | if ( ev->button() == RightButton ) // Configure | 706 | if ( ev->button() == RightButton ) // Configure |
707 | { | 707 | { |
708 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 708 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 712 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
713 | { | 713 | { |
714 | // for auto-hiding the cursor, we need mouseTracking | 714 | // for auto-hiding the cursor, we need mouseTracking |
715 | if (ev->state() == NoButton ) return; | 715 | if (ev->state() == NoButton ) return; |
716 | 716 | ||
717 | if (actSel == 0) return; | 717 | if (actSel == 0) return; |
718 | 718 | ||
719 | // don't extend selection while pasting | 719 | // don't extend selection while pasting |
720 | if (ev->state() & MidButton) return; | 720 | if (ev->state() & MidButton) return; |
721 | 721 | ||
722 | //if ( !contentsRect().contains(ev->pos()) ) return; | 722 | //if ( !contentsRect().contains(ev->pos()) ) return; |
723 | QPoint tL = contentsRect().topLeft(); | 723 | QPoint tL = contentsRect().topLeft(); |
724 | int tLx = tL.x(); | 724 | int tLx = tL.x(); |
725 | int tLy = tL.y(); | 725 | int tLy = tL.y(); |
726 | int scroll = scrollbar->value(); | 726 | int scroll = scrollbar->value(); |
727 | // int hScroll = hScrollbar->value(); | 727 | // int hScroll = hScrollbar->value(); |
728 | 728 | ||
729 | // we're in the process of moving the mouse with the left button pressed | 729 | // we're in the process of moving the mouse with the left button pressed |
730 | // the mouse cursor will kept catched within the bounds of the text in | 730 | // the mouse cursor will kept catched within the bounds of the text in |
731 | // this widget. | 731 | // this widget. |
732 | 732 | ||
733 | // Adjust position within text area bounds. See FIXME above. | 733 | // Adjust position within text area bounds. See FIXME above. |
734 | QPoint pos = ev->pos(); | 734 | QPoint pos = ev->pos(); |
735 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 735 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
736 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 736 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
737 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 737 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
738 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 738 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
739 | // check if we produce a mouse move event by this | 739 | // check if we produce a mouse move event by this |
740 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 740 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
741 | 741 | ||
742 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 742 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
743 | { | 743 | { |
744 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 744 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
745 | } | 745 | } |
746 | if ( pos.y() == tLy+bY ) | 746 | if ( pos.y() == tLy+bY ) |
747 | { | 747 | { |
748 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 748 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
749 | } | 749 | } |
750 | 750 | ||
751 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 751 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
752 | QPoint ohere; | 752 | QPoint ohere; |
753 | bool swapping = FALSE; | 753 | bool swapping = FALSE; |
754 | 754 | ||
755 | if ( word_selection_mode ) | 755 | if ( word_selection_mode ) |
756 | { | 756 | { |
757 | // Extend to word boundaries | 757 | // Extend to word boundaries |
758 | int i; | 758 | int i; |
759 | int selClass; | 759 | int selClass; |
760 | 760 | ||
761 | bool left_not_right = ( here.y() < iPntSel.y() || | 761 | bool left_not_right = ( here.y() < iPntSel.y() || |
762 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 762 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
763 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 763 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
764 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 764 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
765 | swapping = left_not_right != old_left_not_right; | 765 | swapping = left_not_right != old_left_not_right; |
766 | 766 | ||
767 | // Find left (left_not_right ? from here : from start) | 767 | // Find left (left_not_right ? from here : from start) |
768 | QPoint left = left_not_right ? here : iPntSel; | 768 | QPoint left = left_not_right ? here : iPntSel; |
769 | i = loc(left.x(),left.y()); | 769 | i = loc(left.x(),left.y()); |
770 | selClass = charClass(image[i].c); | 770 | selClass = charClass(image[i].c); |
771 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 771 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
772 | { i--; left.rx()--; } | 772 | { i--; left.rx()--; } |
773 | 773 | ||
774 | // Find left (left_not_right ? from start : from here) | 774 | // Find left (left_not_right ? from start : from here) |
775 | QPoint right = left_not_right ? iPntSel : here; | 775 | QPoint right = left_not_right ? iPntSel : here; |
776 | i = loc(right.x(),right.y()); | 776 | i = loc(right.x(),right.y()); |
777 | selClass = charClass(image[i].c); | 777 | selClass = charClass(image[i].c); |
778 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 778 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
779 | { i++; right.rx()++; } | 779 | { i++; right.rx()++; } |
780 | 780 | ||
781 | // Pick which is start (ohere) and which is extension (here) | 781 | // Pick which is start (ohere) and which is extension (here) |
782 | if ( left_not_right ) | 782 | if ( left_not_right ) |
783 | { | 783 | { |
784 | here = left; ohere = right; | 784 | here = left; ohere = right; |
785 | } | 785 | } |
786 | else | 786 | else |
787 | { | 787 | { |
788 | here = right; ohere = left; | 788 | here = right; ohere = left; |
789 | } | 789 | } |
790 | } | 790 | } |
791 | 791 | ||
792 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 792 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
793 | 793 | ||
794 | if ( word_selection_mode ) { | 794 | if ( word_selection_mode ) { |
795 | if ( actSel < 2 || swapping ) { | 795 | if ( actSel < 2 || swapping ) { |
796 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 796 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
797 | } | 797 | } |
798 | } else if ( actSel < 2 ) { | 798 | } else if ( actSel < 2 ) { |
799 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 799 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
800 | } | 800 | } |
801 | 801 | ||
802 | actSel = 2; // within selection | 802 | actSel = 2; // within selection |
803 | pntSel = here; | 803 | pntSel = here; |
804 | emit extendSelectionSignal( here.x(), here.y() ); | 804 | emit extendSelectionSignal( here.x(), here.y() ); |
805 | } | 805 | } |
806 | 806 | ||
807 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 807 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
808 | { | 808 | { |
809 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 809 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
810 | if ( ev->button() == LeftButton) | 810 | if ( ev->button() == LeftButton) |
811 | { | 811 | { |
812 | if (QABS(ev->x() - mouse_down_x) < 3 | 812 | if (QABS(ev->x() - mouse_down_x) < 3 |
813 | && QABS(ev->y() - mouse_down_y) < 3 | 813 | && QABS(ev->y() - mouse_down_y) < 3 |
814 | && ev->y() < qApp->desktop()->height()/8) { | 814 | && ev->y() < qApp->desktop()->height()/8) { |
815 | emit setFullScreen(false); | 815 | emit setFullScreen(false); |
816 | } | 816 | } |
817 | 817 | ||
818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
819 | preserve_line_breaks = TRUE; | 819 | preserve_line_breaks = TRUE; |
820 | actSel = 0; | 820 | actSel = 0; |
821 | 821 | ||
822 | //FIXME: emits a release event even if the mouse is | 822 | //FIXME: emits a release event even if the mouse is |
823 | // outside the range. The procedure used in `mouseMoveEvent' | 823 | // outside the range. The procedure used in `mouseMoveEvent' |
824 | // applies here, too. | 824 | // applies here, too. |
825 | 825 | ||
826 | QPoint tL = contentsRect().topLeft(); | 826 | QPoint tL = contentsRect().topLeft(); |
827 | int tLx = tL.x(); | 827 | int tLx = tL.x(); |
828 | int tLy = tL.y(); | 828 | int tLy = tL.y(); |
829 | 829 | ||
830 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 830 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
831 | emit mouseSignal( 3, // release | 831 | emit mouseSignal( 3, // release |
832 | (ev->x()-tLx-blX)/font_w + 1, | 832 | (ev->x()-tLx-blX)/font_w + 1, |
833 | (ev->y()-tLy-bY)/font_h + 1 ); | 833 | (ev->y()-tLy-bY)/font_h + 1 ); |
834 | releaseMouse(); | 834 | releaseMouse(); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 838 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
839 | { | 839 | { |
840 | if ( ev->button() != LeftButton) return; | 840 | if ( ev->button() != LeftButton) return; |
841 | 841 | ||
842 | QPoint tL = contentsRect().topLeft(); | 842 | QPoint tL = contentsRect().topLeft(); |
843 | int tLx = tL.x(); | 843 | int tLx = tL.x(); |
844 | int tLy = tL.y(); | 844 | int tLy = tL.y(); |
845 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 845 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
846 | 846 | ||
847 | // pass on double click as two clicks. | 847 | // pass on double click as two clicks. |
848 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 848 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
849 | { | 849 | { |
850 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 850 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
851 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 851 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
852 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 852 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
853 | return; | 853 | return; |
854 | } | 854 | } |
855 | 855 | ||
856 | 856 | ||
857 | emit clearSelectionSignal(); | 857 | emit clearSelectionSignal(); |
858 | QPoint bgnSel = pos; | 858 | QPoint bgnSel = pos; |
859 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 859 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
860 | int i = loc(bgnSel.x(),bgnSel.y()); | 860 | int i = loc(bgnSel.x(),bgnSel.y()); |
861 | iPntSel = bgnSel; | 861 | iPntSel = bgnSel; |
862 | 862 | ||
863 | word_selection_mode = TRUE; | 863 | word_selection_mode = TRUE; |
864 | 864 | ||
865 | // find word boundaries... | 865 | // find word boundaries... |
866 | int selClass = charClass(image[i].c); | 866 | int selClass = charClass(image[i].c); |
867 | { | 867 | { |
868 | // set the start... | 868 | // set the start... |
869 | int x = bgnSel.x(); | 869 | int x = bgnSel.x(); |
870 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 870 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
871 | { i--; x--; } | 871 | { i--; x--; } |
872 | bgnSel.setX(x); | 872 | bgnSel.setX(x); |
873 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 873 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
874 | 874 | ||
875 | // set the end... | 875 | // set the end... |
876 | i = loc( endSel.x(), endSel.y() ); | 876 | i = loc( endSel.x(), endSel.y() ); |
877 | x = endSel.x(); | 877 | x = endSel.x(); |
878 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 878 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
879 | { i++; x++ ; } | 879 | { i++; x++ ; } |
880 | endSel.setX(x); | 880 | endSel.setX(x); |
881 | actSel = 2; // within selection | 881 | actSel = 2; // within selection |
882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 882 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
883 | emit endSelectionSignal(preserve_line_breaks); | 883 | emit endSelectionSignal(preserve_line_breaks); |
884 | preserve_line_breaks = TRUE; | 884 | preserve_line_breaks = TRUE; |
885 | } | 885 | } |
886 | } | 886 | } |
887 | 887 | ||
888 | void TEWidget::focusInEvent( QFocusEvent * ) | 888 | void TEWidget::focusInEvent( QFocusEvent * ) |
889 | { | 889 | { |
890 | 890 | ||
891 | // do nothing, to prevent repainting | 891 | // do nothing, to prevent repainting |
892 | } | 892 | } |
893 | 893 | ||
894 | 894 | ||
895 | void TEWidget::focusOutEvent( QFocusEvent * ) | 895 | void TEWidget::focusOutEvent( QFocusEvent * ) |
896 | { | 896 | { |
897 | // do nothing, to prevent repainting | 897 | // do nothing, to prevent repainting |
898 | } | 898 | } |
899 | 899 | ||
900 | bool TEWidget::focusNextPrevChild( bool next ) | 900 | bool TEWidget::focusNextPrevChild( bool next ) |
901 | { | 901 | { |
902 | if (next) | 902 | if (next) |
903 | return false; // This disables changing the active part in konqueror | 903 | return false; // This disables changing the active part in konqueror |
904 | // when pressing Tab | 904 | // when pressing Tab |
905 | return QFrame::focusNextPrevChild( next ); | 905 | return QFrame::focusNextPrevChild( next ); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | int TEWidget::charClass(char ch) const | 909 | int TEWidget::charClass(char ch) const |
910 | { | 910 | { |
911 | // This might seem like overkill, but imagine if ch was a Unicode | 911 | // This might seem like overkill, but imagine if ch was a Unicode |
912 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 912 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
913 | // the different language ranges, etc. | 913 | // the different language ranges, etc. |
914 | 914 | ||
915 | if ( isspace(ch) ) return ' '; | 915 | if ( isspace(ch) ) return ' '; |
916 | 916 | ||
917 | static const char *word_characters = ":@-./_~"; | 917 | static const char *word_characters = ":@-./_~"; |
918 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 918 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
919 | return 'a'; | 919 | return 'a'; |
920 | 920 | ||
921 | // Everything else is weird | 921 | // Everything else is weird |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | void TEWidget::setMouseMarks(bool on) | 925 | void TEWidget::setMouseMarks(bool on) |
926 | { | 926 | { |
927 | mouse_marks = on; | 927 | mouse_marks = on; |
928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 928 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
929 | } | 929 | } |
930 | 930 | ||
931 | /* ------------------------------------------------------------------------- */ | 931 | /* ------------------------------------------------------------------------- */ |
932 | /* */ | 932 | /* */ |
933 | /* Clipboard */ | 933 | /* Clipboard */ |
934 | /* */ | 934 | /* */ |
935 | /* ------------------------------------------------------------------------- */ | 935 | /* ------------------------------------------------------------------------- */ |
936 | 936 | ||
937 | #undef KeyPress | 937 | #undef KeyPress |
938 | 938 | ||
939 | void TEWidget::emitSelection() | 939 | void TEWidget::emitSelection() |
940 | // Paste Clipboard by simulating keypress events | 940 | // Paste Clipboard by simulating keypress events |
941 | { | 941 | { |
942 | #ifndef QT_NO_CLIPBOARD | 942 | #ifndef QT_NO_CLIPBOARD |
943 | QString text = QApplication::clipboard()->text(); | 943 | QString text = QApplication::clipboard()->text(); |
944 | //qDebug(text); | 944 | //qDebug(text); |
945 | if ( ! text.isNull()) | 945 | if ( ! text.isNull()) |
946 | { | 946 | { |
947 | text.replace(QRegExp("\n"), "\r"); | 947 | text.replace(QRegExp("\n"), "\r"); |
948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 948 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
949 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 949 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
950 | emit clearSelectionSignal(); | 950 | emit clearSelectionSignal(); |
951 | } | 951 | } |
952 | #endif | 952 | #endif |
953 | } | 953 | } |
954 | 954 | ||
955 | void TEWidget::emitText(QString text) | 955 | void TEWidget::emitText(QString text) |
956 | { | 956 | { |
957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 957 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
958 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 958 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
959 | } | 959 | } |
960 | 960 | ||
961 | void TEWidget::pasteClipboard( ) | 961 | void TEWidget::pasteClipboard( ) |
962 | { | 962 | { |
963 | emitSelection(); | 963 | emitSelection(); |
964 | } | 964 | } |
965 | 965 | ||
966 | void TEWidget::setSelection(const QString& t) | 966 | void TEWidget::setSelection(const QString& t) |
967 | { | 967 | { |
968 | #ifndef QT_NO_CLIPBOARD | 968 | #ifndef QT_NO_CLIPBOARD |
969 | // Disconnect signal while WE set the clipboard | 969 | // Disconnect signal while WE set the clipboard |
970 | QObject *cb = QApplication::clipboard(); | 970 | QObject *cb = QApplication::clipboard(); |
971 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 971 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
972 | this, SLOT(onClearSelection()) ); | 972 | this, SLOT(onClearSelection()) ); |
973 | 973 | ||
974 | QApplication::clipboard()->setText(t); | 974 | QApplication::clipboard()->setText(t); |
975 | 975 | ||
976 | QObject::connect( cb, SIGNAL(dataChanged()), | 976 | QObject::connect( cb, SIGNAL(dataChanged()), |
977 | this, SLOT(onClearSelection()) ); | 977 | this, SLOT(onClearSelection()) ); |
978 | #endif | 978 | #endif |
979 | } | 979 | } |
980 | 980 | ||
981 | void TEWidget::onClearSelection() | 981 | void TEWidget::onClearSelection() |
982 | { | 982 | { |
983 | emit clearSelectionSignal(); | 983 | emit clearSelectionSignal(); |
984 | } | 984 | } |
985 | 985 | ||
986 | /* ------------------------------------------------------------------------- */ | 986 | /* ------------------------------------------------------------------------- */ |
987 | /* */ | 987 | /* */ |
988 | /* Keyboard */ | 988 | /* Keyboard */ |
989 | /* */ | 989 | /* */ |
990 | /* ------------------------------------------------------------------------- */ | 990 | /* ------------------------------------------------------------------------- */ |
991 | 991 | ||
992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 992 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
993 | // due to a bug in `QT' or the ignorance of the author to prevent | 993 | // due to a bug in `QT' or the ignorance of the author to prevent |
994 | // repaint events being emitted to the screen whenever one leaves | 994 | // repaint events being emitted to the screen whenever one leaves |
995 | // or reenters the screen to/from another application. | 995 | // or reenters the screen to/from another application. |
996 | // | 996 | // |
997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 997 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
998 | // which would also let you have an in-focus cursor and an out-focus | 998 | // which would also let you have an in-focus cursor and an out-focus |
999 | // cursor like xterm does. | 999 | // cursor like xterm does. |
1000 | 1000 | ||
1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 1001 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
1002 | // focusOutEvent() so that update() isn't called. | 1002 | // focusOutEvent() so that update() isn't called. |
1003 | // For auto-hide, we need to get keypress-events, but we only get them when | 1003 | // For auto-hide, we need to get keypress-events, but we only get them when |
1004 | // we have focus. | 1004 | // we have focus. |
1005 | 1005 | ||
1006 | void TEWidget::doScroll(int lines) | 1006 | void TEWidget::doScroll(int lines) |
1007 | { | 1007 | { |
1008 | scrollbar->setValue(scrollbar->value()+lines); | 1008 | scrollbar->setValue(scrollbar->value()+lines); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void TEWidget::doHScroll(int lines) { | 1011 | void TEWidget::doHScroll(int lines) { |
1012 | hScrollbar->setValue( hScrollbar->value()+lines); | 1012 | hScrollbar->setValue( hScrollbar->value()+lines); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1015 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
1016 | { | 1016 | { |
1017 | if ( (e->type() == QEvent::Accel || | 1017 | if ( (e->type() == QEvent::Accel || |
1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1018 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1019 | static_cast<QKeyEvent *>( e )->ignore(); | 1019 | static_cast<QKeyEvent *>( e )->ignore(); |
1020 | return true; | 1020 | return true; |
1021 | } | 1021 | } |
1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1022 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1023 | return FALSE; // not us | 1023 | return FALSE; // not us |
1024 | if ( e->type() == QEvent::Wheel) { | 1024 | if ( e->type() == QEvent::Wheel) { |
1025 | QApplication::sendEvent(scrollbar, e); | 1025 | QApplication::sendEvent(scrollbar, e); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | #ifdef FAKE_CTRL_AND_ALT | 1028 | #ifdef FAKE_CTRL_AND_ALT |
1029 | static bool control = FALSE; | 1029 | static bool control = FALSE; |
1030 | static bool alt = FALSE; | 1030 | static bool alt = FALSE; |
1031 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1031 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1032 | bool dele=FALSE; | 1032 | bool dele=FALSE; |
1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1034 | QKeyEvent* ke = (QKeyEvent*)e; | 1034 | QKeyEvent* ke = (QKeyEvent*)e; |
1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1036 | switch (ke->key()) { | 1036 | switch (ke->key()) { |
1037 | case Key_F9: // let this be "Control" | 1037 | case Key_F9: // let this be "Control" |
1038 | control = keydown; | 1038 | control = keydown; |
1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1040 | dele=TRUE; | 1040 | dele=TRUE; |
1041 | break; | 1041 | break; |
1042 | case Key_F13: // let this be "Alt" | 1042 | case Key_F13: // let this be "Alt" |
1043 | alt = keydown; | 1043 | alt = keydown; |
1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1045 | dele=TRUE; | 1045 | dele=TRUE; |
1046 | break; | 1046 | break; |
1047 | default: | 1047 | default: |
1048 | if ( control ) { | 1048 | if ( control ) { |
1049 | int a = toupper(ke->ascii())-64; | 1049 | int a = toupper(ke->ascii())-64; |
1050 | if ( a >= 0 && a < ' ' ) { | 1050 | if ( a >= 0 && a < ' ' ) { |
1051 | e = new QKeyEvent(e->type(), ke->key(), | 1051 | e = new QKeyEvent(e->type(), ke->key(), |
1052 | a, ke->state()|ControlButton, QChar(a,0)); | 1052 | a, ke->state()|ControlButton, QChar(a,0)); |
1053 | dele=TRUE; | 1053 | dele=TRUE; |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | if ( alt ) { | 1056 | if ( alt ) { |
1057 | e = new QKeyEvent(e->type(), ke->key(), | 1057 | e = new QKeyEvent(e->type(), ke->key(), |
1058 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1058 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1059 | dele=TRUE; | 1059 | dele=TRUE; |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | #endif | 1063 | #endif |
1064 | 1064 | ||
1065 | if ( e->type() == QEvent::KeyPress ) { | 1065 | if ( e->type() == QEvent::KeyPress ) { |
1066 | QKeyEvent* ke = (QKeyEvent*)e; | 1066 | QKeyEvent* ke = (QKeyEvent*)e; |
1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1068 | // know where the current selection is. | 1068 | // know where the current selection is. |
@@ -1136,294 +1136,294 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1136 | special_function = false; | 1136 | special_function = false; |
1137 | } | 1137 | } |
1138 | if (special_function) { | 1138 | if (special_function) { |
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1141 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1142 | // pasteClipboard(); | 1142 | // pasteClipboard(); |
1143 | // } | 1143 | // } |
1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1144 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { |
1145 | // pasteClipboard(); | 1145 | // pasteClipboard(); |
1146 | // } | 1146 | // } |
1147 | emit keyPressedSignal(ke); // expose | 1147 | emit keyPressedSignal(ke); // expose |
1148 | ke->accept(); | 1148 | ke->accept(); |
1149 | #ifdef FAKE_CTRL_AND_ALT | 1149 | #ifdef FAKE_CTRL_AND_ALT |
1150 | if ( dele ) delete e; | 1150 | if ( dele ) delete e; |
1151 | #endif | 1151 | #endif |
1152 | return true; // stop the event | 1152 | return true; // stop the event |
1153 | } | 1153 | } |
1154 | if ( e->type() == QEvent::Enter ) { | 1154 | if ( e->type() == QEvent::Enter ) { |
1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1155 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1156 | this, SLOT(onClearSelection()) ); | 1156 | this, SLOT(onClearSelection()) ); |
1157 | } | 1157 | } |
1158 | if ( e->type() == QEvent::Leave ) { | 1158 | if ( e->type() == QEvent::Leave ) { |
1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1159 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1160 | this, SLOT(onClearSelection()) ); | 1160 | this, SLOT(onClearSelection()) ); |
1161 | } | 1161 | } |
1162 | return QFrame::eventFilter( obj, e ); | 1162 | return QFrame::eventFilter( obj, e ); |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | /* ------------------------------------------------------------------------- */ | 1165 | /* ------------------------------------------------------------------------- */ |
1166 | /* */ | 1166 | /* */ |
1167 | /* Frame */ | 1167 | /* Frame */ |
1168 | /* */ | 1168 | /* */ |
1169 | /* ------------------------------------------------------------------------- */ | 1169 | /* ------------------------------------------------------------------------- */ |
1170 | 1170 | ||
1171 | void TEWidget::frameChanged() | 1171 | void TEWidget::frameChanged() |
1172 | { | 1172 | { |
1173 | propagateSize(); | 1173 | propagateSize(); |
1174 | update(); | 1174 | update(); |
1175 | } | 1175 | } |
1176 | /* ------------------------------------------------------------------------- */ | 1176 | /* ------------------------------------------------------------------------- */ |
1177 | /* */ | 1177 | /* */ |
1178 | /* Sound */ | 1178 | /* Sound */ |
1179 | /* */ | 1179 | /* */ |
1180 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1181 | 1181 | ||
1182 | void TEWidget::Bell() | 1182 | void TEWidget::Bell() |
1183 | { | 1183 | { |
1184 | //#ifdef QT_QWS_SL5XXX | 1184 | //#ifdef QT_QWS_SL5XXX |
1185 | //# ifndef QT_NO_COP | 1185 | //# ifndef QT_NO_COP |
1186 | if(useBeep) | 1186 | if(useBeep) |
1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1187 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); |
1188 | 1188 | ||
1189 | //# endif | 1189 | //# endif |
1190 | //#else | 1190 | //#else |
1191 | //# ifndef QT_NO_SOUND | 1191 | //# ifndef QT_NO_SOUND |
1192 | // QSound::play(Resource::findSound("alarm")); | 1192 | // QSound::play(Resource::findSound("alarm")); |
1193 | //# endif | 1193 | //# endif |
1194 | //#endif | 1194 | //#endif |
1195 | 1195 | ||
1196 | // QApplication::beep(); | 1196 | // QApplication::beep(); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | /* ------------------------------------------------------------------------- */ | 1199 | /* ------------------------------------------------------------------------- */ |
1200 | /* */ | 1200 | /* */ |
1201 | /* Auxiluary */ | 1201 | /* Auxiluary */ |
1202 | /* */ | 1202 | /* */ |
1203 | /* ------------------------------------------------------------------------- */ | 1203 | /* ------------------------------------------------------------------------- */ |
1204 | 1204 | ||
1205 | void TEWidget::clearImage() | 1205 | void TEWidget::clearImage() |
1206 | // initialize the image | 1206 | // initialize the image |
1207 | // for internal use only | 1207 | // for internal use only |
1208 | { | 1208 | { |
1209 | for (int y = 0; y < lines; y++) | 1209 | for (int y = 0; y < lines; y++) |
1210 | for (int x = 0; x < columns; x++) | 1210 | for (int x = 0; x < columns; x++) |
1211 | { | 1211 | { |
1212 | image[loc(x,y)].c = 0xff; //' '; | 1212 | image[loc(x,y)].c = 0xff; //' '; |
1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1213 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1214 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1215 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | // Create Image /////////////////////////////////////////////////////// | 1219 | // Create Image /////////////////////////////////////////////////////// |
1220 | 1220 | ||
1221 | void TEWidget::calcGeometry() | 1221 | void TEWidget::calcGeometry() |
1222 | { | 1222 | { |
1223 | int showhscrollbar = 1; | 1223 | int showhscrollbar = 1; |
1224 | int hwidth = 0; | 1224 | int hwidth = 0; |
1225 | int dcolumns = 0; | 1225 | int dcolumns = 0; |
1226 | Config cfg( "Konsole" ); | 1226 | Config cfg( "Konsole" ); |
1227 | cfg.setGroup("ScrollBar"); | 1227 | cfg.setGroup("ScrollBar"); |
1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1228 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1229 | 1229 | ||
1230 | if(vcolumns == 0) showhscrollbar = 0; | 1230 | if(vcolumns == 0) showhscrollbar = 0; |
1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1231 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1232 | 1232 | ||
1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1233 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1234 | contentsRect().height() - hwidth); | 1234 | contentsRect().height() - hwidth); |
1235 | 1235 | ||
1236 | switch(scrollLoc) { | 1236 | switch(scrollLoc) { |
1237 | case SCRNONE : | 1237 | case SCRNONE : |
1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1238 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1239 | dcolumns = columns; | 1239 | dcolumns = columns; |
1240 | if(vcolumns) columns = vcolumns; | 1240 | if(vcolumns) columns = vcolumns; |
1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1241 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1242 | if(showhscrollbar) | 1242 | if(showhscrollbar) |
1243 | blX = -hposition * font_w; | 1243 | blX = -hposition * font_w; |
1244 | brX = blX; | 1244 | brX = blX; |
1245 | scrollbar->hide(); | 1245 | scrollbar->hide(); |
1246 | break; | 1246 | break; |
1247 | case SCRLEFT : | 1247 | case SCRLEFT : |
1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1248 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1249 | dcolumns = columns; | 1249 | dcolumns = columns; |
1250 | if(vcolumns) columns = vcolumns; | 1250 | if(vcolumns) columns = vcolumns; |
1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1251 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1252 | if(showhscrollbar) | 1252 | if(showhscrollbar) |
1253 | brX = -hposition * font_w; | 1253 | brX = -hposition * font_w; |
1254 | blX = brX + scrollbar->width(); | 1254 | blX = brX + scrollbar->width(); |
1255 | scrollbar->move(contentsRect().topLeft()); | 1255 | scrollbar->move(contentsRect().topLeft()); |
1256 | scrollbar->show(); | 1256 | scrollbar->show(); |
1257 | break; | 1257 | break; |
1258 | case SCRRIGHT: | 1258 | case SCRRIGHT: |
1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1259 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1260 | dcolumns = columns; | 1260 | dcolumns = columns; |
1261 | if(vcolumns) columns = vcolumns; | 1261 | if(vcolumns) columns = vcolumns; |
1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1262 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1263 | if(showhscrollbar) | 1263 | if(showhscrollbar) |
1264 | blX = -hposition * font_w; | 1264 | blX = -hposition * font_w; |
1265 | brX = blX; | 1265 | brX = blX; |
1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1266 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1267 | scrollbar->show(); | 1267 | scrollbar->show(); |
1268 | break; | 1268 | break; |
1269 | } | 1269 | } |
1270 | //FIXME: support 'rounding' styles | 1270 | //FIXME: support 'rounding' styles |
1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1271 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1272 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1273 | 1273 | ||
1274 | if(showhscrollbar == 1) { | 1274 | if(showhscrollbar == 1) { |
1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1275 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1276 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1276 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1277 | 1277 | ||
1278 | QPoint p = contentsRect().bottomLeft(); | 1278 | QPoint p = contentsRect().bottomLeft(); |
1279 | if(scrollLoc == SCRLEFT) | 1279 | if(scrollLoc == SCRLEFT) |
1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); | 1280 | hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); |
1281 | else | 1281 | else |
1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1282 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1283 | 1283 | ||
1284 | hScrollbar->show(); | 1284 | hScrollbar->show(); |
1285 | } | 1285 | } |
1286 | else hScrollbar->hide(); | 1286 | else hScrollbar->hide(); |
1287 | 1287 | ||
1288 | if(showhscrollbar == 1) { | 1288 | if(showhscrollbar == 1) { |
1289 | lines = lines - (hwidth / font_h) - 1; | 1289 | lines = lines - (hwidth / font_h) - 1; |
1290 | if(lines < 1) lines = 1; | 1290 | if(lines < 1) lines = 1; |
1291 | } | 1291 | } |
1292 | //FIXME: support 'rounding' styles | 1292 | //FIXME: support 'rounding' styles |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void TEWidget::makeImage() | 1295 | void TEWidget::makeImage() |
1296 | //FIXME: rename 'calcGeometry? | 1296 | //FIXME: rename 'calcGeometry? |
1297 | { | 1297 | { |
1298 | calcGeometry(); | 1298 | calcGeometry(); |
1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1299 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1300 | clearImage(); | 1300 | clearImage(); |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | // calculate the needed size | 1303 | // calculate the needed size |
1304 | QSize TEWidget::calcSize(int cols, int lins) const | 1304 | QSize TEWidget::calcSize(int cols, int lins) const |
1305 | { | 1305 | { |
1306 | int frw = width() - contentsRect().width(); | 1306 | int frw = width() - contentsRect().width(); |
1307 | int frh = height() - contentsRect().height(); | 1307 | int frh = height() - contentsRect().height(); |
1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1308 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1309 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | QSize TEWidget::sizeHint() const | 1312 | QSize TEWidget::sizeHint() const |
1313 | { | 1313 | { |
1314 | return size(); | 1314 | return size(); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void TEWidget::styleChange(QStyle &) | 1317 | void TEWidget::styleChange(QStyle &) |
1318 | { | 1318 | { |
1319 | propagateSize(); | 1319 | propagateSize(); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | #ifndef QT_NO_DRAGANDDROP | 1322 | #ifndef QT_NO_DRAGANDDROP |
1323 | 1323 | ||
1324 | /* --------------------------------------------------------------------- */ | 1324 | /* --------------------------------------------------------------------- */ |
1325 | /* */ | 1325 | /* */ |
1326 | /* Drag & Drop */ | 1326 | /* Drag & Drop */ |
1327 | /* */ | 1327 | /* */ |
1328 | /* --------------------------------------------------------------------- */ | 1328 | /* --------------------------------------------------------------------- */ |
1329 | 1329 | ||
1330 | 1330 | ||
1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1331 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1332 | { | 1332 | { |
1333 | e->accept(QTextDrag::canDecode(e) || | 1333 | e->accept(QTextDrag::canDecode(e) || |
1334 | QUriDrag::canDecode(e)); | 1334 | QUriDrag::canDecode(e)); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | void TEWidget::dropEvent(QDropEvent* event) | 1337 | void TEWidget::dropEvent(QDropEvent* event) |
1338 | { | 1338 | { |
1339 | // The current behaviour when url(s) are dropped is | 1339 | // The current behaviour when url(s) are dropped is |
1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1340 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1341 | // * in all other cases, just paste | 1341 | // * in all other cases, just paste |
1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1342 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1343 | QStrList strlist; | 1343 | QStrList strlist; |
1344 | int file_count = 0; | 1344 | int file_count = 0; |
1345 | dropText = ""; | 1345 | dropText = ""; |
1346 | bool bPopup = true; | 1346 | bool bPopup = true; |
1347 | 1347 | ||
1348 | if(QUriDrag::decode(event, strlist)) { | 1348 | if(QUriDrag::decode(event, strlist)) { |
1349 | if (strlist.count()) { | 1349 | if (strlist.count()) { |
1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1350 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1351 | if(file_count++ > 0) { | 1351 | if(file_count++ > 0) { |
1352 | dropText += " "; | 1352 | dropText += " "; |
1353 | bPopup = false; // more than one file, don't popup | 1353 | bPopup = false; // more than one file, don't popup |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | /* | 1356 | /* |
1357 | KURL url(p); | 1357 | KURL url(p); |
1358 | if (url.isLocalFile()) { | 1358 | if (url.isLocalFile()) { |
1359 | dropText += url.path(); // local URL : remove protocol | 1359 | dropText += url.path(); // local URL : remove protocol |
1360 | } | 1360 | } |
1361 | else { | 1361 | else { |
1362 | dropText += url.prettyURL(); | 1362 | dropText += url.prettyURL(); |
1363 | bPopup = false; // a non-local file, don't popup | 1363 | bPopup = false; // a non-local file, don't popup |
1364 | } | 1364 | } |
1365 | */ | 1365 | */ |
1366 | 1366 | ||
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | if (bPopup) | 1369 | if (bPopup) |
1370 | // m_drop->popup(pos() + event->pos()); | 1370 | // m_drop->popup(pos() + event->pos()); |
1371 | m_drop->popup(mapToGlobal(event->pos())); | 1371 | m_drop->popup(mapToGlobal(event->pos())); |
1372 | else | 1372 | else |
1373 | { | 1373 | { |
1374 | if (currentSession) { | 1374 | if (currentSession) { |
1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1375 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1376 | } | 1376 | } |
1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1377 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | else if(QTextDrag::decode(event, dropText)) { | 1381 | else if(QTextDrag::decode(event, dropText)) { |
1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1382 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1383 | if (currentSession) { | 1383 | if (currentSession) { |
1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1384 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1385 | } | 1385 | } |
1386 | // Paste it | 1386 | // Paste it |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | #endif | 1389 | #endif |
1390 | 1390 | ||
1391 | 1391 | ||
1392 | void TEWidget::drop_menu_activated(int item) | 1392 | void TEWidget::drop_menu_activated(int /*item*/) |
1393 | { | 1393 | { |
1394 | #ifndef QT_NO_DRAGANDDROP | 1394 | #ifndef QT_NO_DRAGANDDROP |
1395 | switch (item) | 1395 | switch (item) |
1396 | { | 1396 | { |
1397 | case 0: // paste | 1397 | case 0: // paste |
1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1398 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1399 | // KWM::activate((Window)this->winId()); | 1399 | // KWM::activate((Window)this->winId()); |
1400 | break; | 1400 | break; |
1401 | case 1: // cd ... | 1401 | case 1: // cd ... |
1402 | currentSession->getEmulation()->sendString("cd "); | 1402 | currentSession->getEmulation()->sendString("cd "); |
1403 | struct stat statbuf; | 1403 | struct stat statbuf; |
1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1404 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1405 | { | 1405 | { |
1406 | if ( !S_ISDIR(statbuf.st_mode) ) | 1406 | if ( !S_ISDIR(statbuf.st_mode) ) |
1407 | { | 1407 | { |
1408 | /* | 1408 | /* |
1409 | KURL url; | 1409 | KURL url; |
1410 | url.setPath( dropText ); | 1410 | url.setPath( dropText ); |
1411 | dropText = url.directory( true, false ); // remove filename | 1411 | dropText = url.directory( true, false ); // remove filename |
1412 | */ | 1412 | */ |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1415 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1416 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1417 | currentSession->getEmulation()->sendString("\n"); | 1417 | currentSession->getEmulation()->sendString("\n"); |
1418 | // KWM::activate((Window)this->winId()); | 1418 | // KWM::activate((Window)this->winId()); |
1419 | break; | 1419 | break; |
1420 | } | 1420 | } |
1421 | #endif | 1421 | #endif |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | void TEWidget::setWrapAt(int columns) | 1424 | void TEWidget::setWrapAt(int columns) |
1425 | { | 1425 | { |
1426 | vcolumns = columns; | 1426 | vcolumns = columns; |
1427 | propagateSize(); | 1427 | propagateSize(); |
1428 | update(); | 1428 | update(); |
1429 | } | 1429 | } |
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index c5df47f..cbea7bd 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -257,521 +257,512 @@ Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | |||
257 | struct HistoryItem | 257 | struct HistoryItem |
258 | { | 258 | { |
259 | HistoryItem(int c, const QString &l) | 259 | HistoryItem(int c, const QString &l) |
260 | { | 260 | { |
261 | count = c; | 261 | count = c; |
262 | line = l; | 262 | line = l; |
263 | } | 263 | } |
264 | int count; | 264 | int count; |
265 | QString line; | 265 | QString line; |
266 | }; | 266 | }; |
267 | 267 | ||
268 | class HistoryList : public QList<HistoryItem> | 268 | class HistoryList : public QList<HistoryItem> |
269 | { | 269 | { |
270 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 270 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
271 | { | 271 | { |
272 | int c1 = ((HistoryItem*)item1)->count; | 272 | int c1 = ((HistoryItem*)item1)->count; |
273 | int c2 = ((HistoryItem*)item2)->count; | 273 | int c2 = ((HistoryItem*)item2)->count; |
274 | if (c1 > c2) | 274 | if (c1 > c2) |
275 | return(1); | 275 | return(1); |
276 | if (c1 < c2) | 276 | if (c1 < c2) |
277 | return(-1); | 277 | return(-1); |
278 | return(0); | 278 | return(0); |
279 | } | 279 | } |
280 | }; | 280 | }; |
281 | 281 | ||
282 | void Konsole::initCommandList() | 282 | void Konsole::initCommandList() |
283 | { | 283 | { |
284 | // qDebug("Konsole::initCommandList"); | 284 | // qDebug("Konsole::initCommandList"); |
285 | Config cfg( "Konsole" ); | 285 | Config cfg( "Konsole" ); |
286 | cfg.setGroup("Commands"); | 286 | cfg.setGroup("Commands"); |
287 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 287 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
288 | commonCombo->clear(); | 288 | commonCombo->clear(); |
289 | 289 | ||
290 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 290 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
291 | { | 291 | { |
292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
294 | QFile histfile(histfilename); | 294 | QFile histfile(histfilename); |
295 | // note: compiler barfed on: | 295 | // note: compiler barfed on: |
296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
297 | if (histfile.open( IO_ReadOnly )) | 297 | if (histfile.open( IO_ReadOnly )) |
298 | { | 298 | { |
299 | QString line; | 299 | QString line; |
300 | uint i; | 300 | uint i; |
301 | HistoryList items; | 301 | HistoryList items; |
302 | 302 | ||
303 | int lineno = 0; | 303 | int lineno = 0; |
304 | while(!histfile.atEnd()) | 304 | while(!histfile.atEnd()) |
305 | { | 305 | { |
306 | if (histfile.readLine(line, 200) < 0) | 306 | if (histfile.readLine(line, 200) < 0) |
307 | { | 307 | { |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | line = line.left(line.length()-1); | 310 | line = line.left(line.length()-1); |
311 | lineno++; | 311 | lineno++; |
312 | 312 | ||
313 | for(i=0; i<items.count(); i++) | 313 | for(i=0; i<items.count(); i++) |
314 | { | 314 | { |
315 | if (line == items.at(i)->line) | 315 | if (line == items.at(i)->line) |
316 | { | 316 | { |
317 | // weight recent commands & repeated commands more | 317 | // weight recent commands & repeated commands more |
318 | // by adding up the index of each command | 318 | // by adding up the index of each command |
319 | items.at(i)->count += lineno; | 319 | items.at(i)->count += lineno; |
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | if (i >= items.count()) | 323 | if (i >= items.count()) |
324 | { | 324 | { |
325 | items.append(new HistoryItem(lineno, line)); | 325 | items.append(new HistoryItem(lineno, line)); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | items.sort(); | 328 | items.sort(); |
329 | int n = items.count(); | 329 | int n = items.count(); |
330 | if (n > 40) | 330 | if (n > 40) |
331 | { | 331 | { |
332 | n = 40; | 332 | n = 40; |
333 | } | 333 | } |
334 | for(int i=0; i<n; i++) | 334 | for(int i=0; i<n; i++) |
335 | { | 335 | { |
336 | // should insert start of command, but keep whole thing | 336 | // should insert start of command, but keep whole thing |
337 | if (items.at(items.count()-i-1)->line.length() < 30) | 337 | if (items.at(items.count()-i-1)->line.length() < 30) |
338 | { | 338 | { |
339 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 339 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | histfile.close(); | 342 | histfile.close(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 345 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
346 | { | 346 | { |
347 | for (int i = 0; commonCmds[i] != NULL; i++) | 347 | for (int i = 0; commonCmds[i] != NULL; i++) |
348 | { | 348 | { |
349 | commonCombo->insertItem(commonCmds[i]); | 349 | commonCombo->insertItem(commonCmds[i]); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | else | 352 | else |
353 | { | 353 | { |
354 | for (int i = 0; i < 100; i++) | 354 | for (int i = 0; i < 100; i++) |
355 | { | 355 | { |
356 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 356 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
357 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 357 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | static void sig_handler(int x) | 364 | static void sig_handler(int x) |
365 | { | 365 | { |
366 | printf("got signal %d\n",x); | 366 | printf("got signal %d\n",x); |
367 | } | 367 | } |
368 | 368 | ||
369 | void Konsole::init(const char* _pgm, QStrList & _args) | 369 | void Konsole::init(const char* _pgm, QStrList & _args) |
370 | { | 370 | { |
371 | 371 | ||
372 | #if 0 | 372 | #if 0 |
373 | for(int i=1; i<=31; i++) | 373 | for(int i=1; i<=31; i++) |
374 | { | 374 | { |
375 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 375 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
376 | && i != SIGINT && i != SIGILL && i != SIGTERM | 376 | && i != SIGINT && i != SIGILL && i != SIGTERM |
377 | && i != SIGBUS) | 377 | && i != SIGBUS) |
378 | signal(i,sig_handler); | 378 | signal(i,sig_handler); |
379 | } | 379 | } |
380 | #endif | 380 | #endif |
381 | signal(SIGSTOP, sig_handler); | 381 | signal(SIGSTOP, sig_handler); |
382 | signal(SIGCONT, sig_handler); | 382 | signal(SIGCONT, sig_handler); |
383 | signal(SIGTSTP, sig_handler); | 383 | signal(SIGTSTP, sig_handler); |
384 | 384 | ||
385 | b_scroll = TRUE; // histon; | 385 | b_scroll = TRUE; // histon; |
386 | n_keytab = 0; | 386 | n_keytab = 0; |
387 | n_render = 0; | 387 | n_render = 0; |
388 | startUp=0; | 388 | startUp=0; |
389 | fromMenu = FALSE; | 389 | fromMenu = FALSE; |
390 | fullscreen = false; | 390 | fullscreen = false; |
391 | 391 | ||
392 | setCaption( tr( "Konsole" ) ); | 392 | setCaption( tr( "Konsole" ) ); |
393 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 393 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
394 | 394 | ||
395 | Config cfg( "Konsole" ); | 395 | Config cfg( "Konsole" ); |
396 | cfg.setGroup("Font"); | 396 | cfg.setGroup("Font"); |
397 | QString tmp; | 397 | QString tmp; |
398 | 398 | ||
399 | // initialize the list of allowed fonts /////////////////////////////////// | 399 | // initialize the list of allowed fonts /////////////////////////////////// |
400 | 400 | ||
401 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 401 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
402 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 402 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
403 | 403 | ||
404 | cfont = -1; | 404 | cfont = -1; |
405 | 405 | ||
406 | // this code causes repeated access to all the font files | 406 | // this code causes repeated access to all the font files |
407 | // which does slow down startup | 407 | // which does slow down startup |
408 | QFontDatabase fontDB; | 408 | QFontDatabase fontDB; |
409 | QStringList familyNames; | 409 | QStringList familyNames; |
410 | familyNames = fontDB.families( FALSE ); | 410 | familyNames = fontDB.families( FALSE ); |
411 | QString s; | 411 | QString s; |
412 | int fontIndex = 0; | 412 | int fontIndex = 0; |
413 | int familyNum = 0; | 413 | int familyNum = 0; |
414 | fontList = new QPopupMenu( this ); | 414 | fontList = new QPopupMenu( this ); |
415 | 415 | ||
416 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 416 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
417 | { | 417 | { |
418 | s = familyNames[j]; | 418 | s = familyNames[j]; |
419 | if ( s.contains('-') ) | 419 | if ( s.contains('-') ) |
420 | { | 420 | { |
421 | int i = s.find('-'); | 421 | int i = s.find('-'); |
422 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 422 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
423 | } | 423 | } |
424 | s[0] = s[0].upper(); | 424 | s[0] = s[0].upper(); |
425 | 425 | ||
426 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 426 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
427 | 427 | ||
428 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 428 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
429 | sizes.count()); | 429 | sizes.count()); |
430 | 430 | ||
431 | if (sizes.count() > 0) | 431 | if (sizes.count() > 0) |
432 | { | 432 | { |
433 | QPopupMenu *sizeMenu; | 433 | QPopupMenu *sizeMenu; |
434 | QFont f; | 434 | QFont f; |
435 | int last_width = -1; | 435 | int last_width = -1; |
436 | sizeMenu = NULL; | 436 | sizeMenu = NULL; |
437 | 437 | ||
438 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 438 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
439 | { | 439 | { |
440 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 440 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
441 | // need to divide by 10 on the Z, but not otherwise | 441 | // need to divide by 10 on the Z, but not otherwise |
442 | int size; | 442 | int size; |
443 | 443 | ||
444 | if (i >= (uint)sizes.count()) | 444 | if (i >= (uint)sizes.count()) |
445 | { | 445 | { |
446 | // try for expandable fonts | 446 | // try for expandable fonts |
447 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 447 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
448 | } | 448 | } |
449 | else | 449 | else |
450 | { | 450 | { |
451 | printf("sizes[%d] = %d\n", i, sizes[i]); | 451 | printf("sizes[%d] = %d\n", i, sizes[i]); |
452 | size = sizes[i]; | 452 | size = sizes[i]; |
453 | } | 453 | } |
454 | 454 | ||
455 | f = QFont(familyNames[j], size); | 455 | f = QFont(familyNames[j], size); |
456 | f.setFixedPitch(true); | 456 | f.setFixedPitch(true); |
457 | QFontMetrics fm(f); | 457 | QFontMetrics fm(f); |
458 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 458 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
459 | if (fm.width("l") == fm.width("m") | 459 | if (fm.width("l") == fm.width("m") |
460 | && (i < (uint)sizes.count() | 460 | && (i < (uint)sizes.count() |
461 | || fm.width("m") > last_width)) | 461 | || fm.width("m") > last_width)) |
462 | { | 462 | { |
463 | if (i < (uint)sizes.count()) | 463 | if (i < (uint)sizes.count()) |
464 | { | 464 | { |
465 | last_width = fm.width("m"); | 465 | last_width = fm.width("m"); |
466 | } | 466 | } |
467 | if (sizeMenu == NULL) | 467 | if (sizeMenu == NULL) |
468 | { | 468 | { |
469 | sizeMenu = new QPopupMenu(); | 469 | sizeMenu = new QPopupMenu(); |
470 | } | 470 | } |
471 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 471 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
472 | sizeMenu->setItemParameter(id, fontIndex); | 472 | sizeMenu->setItemParameter(id, fontIndex); |
473 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 473 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
474 | QString name = s + " " + QString::number(size); | 474 | QString name = s + " " + QString::number(size); |
475 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 475 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
476 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 476 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
477 | { | 477 | { |
478 | cfont = fontIndex; | 478 | cfont = fontIndex; |
479 | } | 479 | } |
480 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 480 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
481 | fontIndex++; | 481 | fontIndex++; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | if (sizeMenu) | 484 | if (sizeMenu) |
485 | { | 485 | { |
486 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 486 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
487 | 487 | ||
488 | familyNum++; | 488 | familyNum++; |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | } | 492 | } |
493 | 493 | ||
494 | if (cfont < 0 || cfont >= (int)fonts.count()) | 494 | if (cfont < 0 || cfont >= (int)fonts.count()) |
495 | { | 495 | { |
496 | cfont = 0; | 496 | cfont = 0; |
497 | } | 497 | } |
498 | 498 | ||
499 | // create terminal emulation framework //////////////////////////////////// | 499 | // create terminal emulation framework //////////////////////////////////// |
500 | nsessions = 0; | 500 | nsessions = 0; |
501 | 501 | ||
502 | tab = new EKNumTabWidget(this); | 502 | tab = new EKNumTabWidget(this); |
503 | // tab->setMargin(tab->margin()-5); | 503 | // tab->setMargin(tab->margin()-5); |
504 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 504 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
505 | 505 | ||
506 | // create terminal toolbar //////////////////////////////////////////////// | 506 | // create terminal toolbar //////////////////////////////////////////////// |
507 | setToolBarsMovable( FALSE ); | 507 | setToolBarsMovable( FALSE ); |
508 | menuToolBar = new QToolBar( this ); | 508 | menuToolBar = new QToolBar( this ); |
509 | menuToolBar->setHorizontalStretchable( TRUE ); | 509 | menuToolBar->setHorizontalStretchable( TRUE ); |
510 | 510 | ||
511 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 511 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
512 | 512 | ||
513 | bool c7xx = false; | ||
514 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | ||
515 | { | ||
516 | c7xx = true; | ||
517 | } | ||
518 | QFont menuFont; | ||
519 | menuFont.setPointSize(c7xx? 18 : 10); | ||
520 | qApp->setFont(menuFont, true); | ||
521 | |||
522 | setFont(cfont); | 513 | setFont(cfont); |
523 | 514 | ||
524 | configMenu = new QPopupMenu( this); | 515 | configMenu = new QPopupMenu( this); |
525 | colorMenu = new QPopupMenu( this); | 516 | colorMenu = new QPopupMenu( this); |
526 | scrollMenu = new QPopupMenu( this); | 517 | scrollMenu = new QPopupMenu( this); |
527 | editCommandListMenu = new QPopupMenu( this); | 518 | editCommandListMenu = new QPopupMenu( this); |
528 | 519 | ||
529 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 520 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
530 | 521 | ||
531 | bool listHidden; | 522 | bool listHidden; |
532 | cfg.setGroup("Menubar"); | 523 | cfg.setGroup("Menubar"); |
533 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 524 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
534 | { | 525 | { |
535 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 526 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
536 | listHidden=TRUE; | 527 | listHidden=TRUE; |
537 | } | 528 | } |
538 | else | 529 | else |
539 | { | 530 | { |
540 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 531 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
541 | listHidden=FALSE; | 532 | listHidden=FALSE; |
542 | } | 533 | } |
543 | 534 | ||
544 | cfg.setGroup("Tabs"); | 535 | cfg.setGroup("Tabs"); |
545 | 536 | ||
546 | tabMenu = new QPopupMenu(this); | 537 | tabMenu = new QPopupMenu(this); |
547 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 538 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
548 | tm_top = tabMenu->insertItem(tr("Top")); | 539 | tm_top = tabMenu->insertItem(tr("Top")); |
549 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 540 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
550 | 541 | ||
551 | configMenu->insertItem(tr("Tabs"), tabMenu); | 542 | configMenu->insertItem(tr("Tabs"), tabMenu); |
552 | 543 | ||
553 | tmp=cfg.readEntry("Position","Top"); | 544 | tmp=cfg.readEntry("Position","Top"); |
554 | if(tmp=="Top") | 545 | if(tmp=="Top") |
555 | { | 546 | { |
556 | tab->setTabPosition(QTabWidget::Top); | 547 | tab->setTabPosition(QTabWidget::Top); |
557 | tab->getTabBar()->show(); | 548 | tab->getTabBar()->show(); |
558 | tabPos = tm_top; | 549 | tabPos = tm_top; |
559 | } | 550 | } |
560 | else if (tmp=="Bottom") | 551 | else if (tmp=="Bottom") |
561 | { | 552 | { |
562 | tab->setTabPosition(QTabWidget::Bottom); | 553 | tab->setTabPosition(QTabWidget::Bottom); |
563 | tab->getTabBar()->show(); | 554 | tab->getTabBar()->show(); |
564 | tabPos = tm_bottom; | 555 | tabPos = tm_bottom; |
565 | } | 556 | } |
566 | else | 557 | else |
567 | { | 558 | { |
568 | tab->getTabBar()->hide(); | 559 | tab->getTabBar()->hide(); |
569 | tab->setMargin(tab->margin()); | 560 | tab->setMargin(tab->margin()); |
570 | tabPos = tm_hidden; | 561 | tabPos = tm_hidden; |
571 | } | 562 | } |
572 | 563 | ||
573 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 564 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
574 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 565 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
575 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 566 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
576 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 567 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
577 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 568 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
578 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 569 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
579 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 570 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
580 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 571 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
581 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 572 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
582 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 573 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
583 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 574 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
584 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 575 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
585 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 576 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
586 | cm_default = colorMenu->insertItem(tr("default")); | 577 | cm_default = colorMenu->insertItem(tr("default")); |
587 | 578 | ||
588 | #ifdef QT_QWS_OPIE | 579 | #ifdef QT_QWS_OPIE |
589 | 580 | ||
590 | colorMenu->insertItem(tr( "Custom")); | 581 | colorMenu->insertItem(tr( "Custom")); |
591 | #endif | 582 | #endif |
592 | 583 | ||
593 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 584 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
594 | 585 | ||
595 | sessionList = new QPopupMenu(this); | 586 | sessionList = new QPopupMenu(this); |
596 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 587 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
597 | SLOT(newSession()) ); | 588 | SLOT(newSession()) ); |
598 | 589 | ||
599 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 590 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
600 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 591 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
601 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 592 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
602 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 593 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
603 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 594 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
604 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 595 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
605 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 596 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
606 | 597 | ||
607 | menuBar->insertItem( tr("View"), configMenu ); | 598 | menuBar->insertItem( tr("View"), configMenu ); |
608 | menuBar->insertItem( tr("Fonts"), fontList ); | 599 | menuBar->insertItem( tr("Fonts"), fontList ); |
609 | menuBar->insertItem( tr("Sessions"), sessionList ); | 600 | menuBar->insertItem( tr("Sessions"), sessionList ); |
610 | 601 | ||
611 | toolBar = new QToolBar( this ); | 602 | toolBar = new QToolBar( this ); |
612 | 603 | ||
613 | QAction *a; | 604 | QAction *a; |
614 | 605 | ||
615 | // Button Commands | 606 | // Button Commands |
616 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 607 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
617 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 608 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
618 | a->addTo( toolBar ); | 609 | a->addTo( toolBar ); |
619 | 610 | ||
620 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 611 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
621 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 612 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
622 | a->addTo( toolBar ); | 613 | a->addTo( toolBar ); |
623 | 614 | ||
624 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 615 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
625 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 616 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
626 | a->addTo( toolBar ); | 617 | a->addTo( toolBar ); |
627 | 618 | ||
628 | 619 | ||
629 | /* | 620 | /* |
630 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 621 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
631 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 622 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
632 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 623 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
633 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 624 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
634 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 625 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
635 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 626 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
636 | */ | 627 | */ |
637 | /* | 628 | /* |
638 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 629 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
639 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 630 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
640 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 631 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
641 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 632 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
642 | */ | 633 | */ |
643 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 634 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
644 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 635 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
645 | a->addTo( toolBar ); | 636 | a->addTo( toolBar ); |
646 | 637 | ||
647 | secondToolBar = new QToolBar( this ); | 638 | secondToolBar = new QToolBar( this ); |
648 | secondToolBar->setHorizontalStretchable( TRUE ); | 639 | secondToolBar->setHorizontalStretchable( TRUE ); |
649 | 640 | ||
650 | commonCombo = new QComboBox( secondToolBar ); | 641 | commonCombo = new QComboBox( secondToolBar ); |
651 | // commonCombo->setMaximumWidth(236); | 642 | // commonCombo->setMaximumWidth(236); |
652 | 643 | ||
653 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 644 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
654 | if( listHidden) | 645 | if( listHidden) |
655 | { | 646 | { |
656 | secondToolBar->hide(); | 647 | secondToolBar->hide(); |
657 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 648 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
658 | } | 649 | } |
659 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 650 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
660 | 651 | ||
661 | cfg.setGroup("Commands"); | 652 | cfg.setGroup("Commands"); |
662 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 653 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
663 | 654 | ||
664 | initCommandList(); | 655 | initCommandList(); |
665 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 656 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
666 | // commonCombo->insertItem( commonCmds[i], i ); | 657 | // commonCombo->insertItem( commonCmds[i], i ); |
667 | // tmp = cfg.readEntry( QString::number(i),""); | 658 | // tmp = cfg.readEntry( QString::number(i),""); |
668 | // if(tmp != "") | 659 | // if(tmp != "") |
669 | // commonCombo->changeItem( tmp,i ); | 660 | // commonCombo->changeItem( tmp,i ); |
670 | // } | 661 | // } |
671 | 662 | ||
672 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 663 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
673 | 664 | ||
674 | sm_none = scrollMenu->insertItem(tr( "None" )); | 665 | sm_none = scrollMenu->insertItem(tr( "None" )); |
675 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 666 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
676 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 667 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
677 | // scrollMenu->insertSeparator(4); | 668 | // scrollMenu->insertSeparator(4); |
678 | // scrollMenu->insertItem(tr( "Horizontal" )); | 669 | // scrollMenu->insertItem(tr( "Horizontal" )); |
679 | 670 | ||
680 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 671 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
681 | 672 | ||
682 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 673 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
683 | 674 | ||
684 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 675 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
685 | cfg.setGroup("ScrollBar"); | 676 | cfg.setGroup("ScrollBar"); |
686 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 677 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
687 | 678 | ||
688 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 679 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
689 | cfg.setGroup("Menubar"); | 680 | cfg.setGroup("Menubar"); |
690 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 681 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
691 | 682 | ||
692 | fullscreen_msg = new QLabel(this); | 683 | fullscreen_msg = new QLabel(this); |
693 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 684 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
694 | fullscreen_msg-> hide(); | 685 | fullscreen_msg-> hide(); |
695 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 686 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
696 | fullscreen_msg-> setAutoResize(true); | 687 | fullscreen_msg-> setAutoResize(true); |
697 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 688 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
698 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 689 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
699 | 690 | ||
700 | fullscreen_timer = new QTimer(this); | 691 | fullscreen_timer = new QTimer(this); |
701 | connect(fullscreen_timer, SIGNAL(timeout()), | 692 | connect(fullscreen_timer, SIGNAL(timeout()), |
702 | this, SLOT(fullscreenTimeout())); | 693 | this, SLOT(fullscreenTimeout())); |
703 | show_fullscreen_msg = true; | 694 | show_fullscreen_msg = true; |
704 | 695 | ||
705 | //scrollMenuSelected(-29); | 696 | //scrollMenuSelected(-29); |
706 | // cfg.setGroup("ScrollBar"); | 697 | // cfg.setGroup("ScrollBar"); |
707 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 698 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
708 | // if(cfg.readNumEntry("Position",2) == 0) | 699 | // if(cfg.readNumEntry("Position",2) == 0) |
709 | // te->setScrollbarLocation(1); | 700 | // te->setScrollbarLocation(1); |
710 | // else | 701 | // else |
711 | // te->setScrollbarLocation(0); | 702 | // te->setScrollbarLocation(0); |
712 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 703 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
713 | // te->setWrapAt(120); | 704 | // te->setWrapAt(120); |
714 | // } | 705 | // } |
715 | // create applications ///////////////////////////////////////////////////// | 706 | // create applications ///////////////////////////////////////////////////// |
716 | setCentralWidget(tab); | 707 | setCentralWidget(tab); |
717 | 708 | ||
718 | // load keymaps //////////////////////////////////////////////////////////// | 709 | // load keymaps //////////////////////////////////////////////////////////// |
719 | KeyTrans::loadAll(); | 710 | KeyTrans::loadAll(); |
720 | for (int i = 0; i < KeyTrans::count(); i++) | 711 | for (int i = 0; i < KeyTrans::count(); i++) |
721 | { | 712 | { |
722 | KeyTrans* s = KeyTrans::find(i); | 713 | KeyTrans* s = KeyTrans::find(i); |
723 | assert( s ); | 714 | assert( s ); |
724 | } | 715 | } |
725 | 716 | ||
726 | se_pgm = _pgm; | 717 | se_pgm = _pgm; |
727 | se_args = _args; | 718 | se_args = _args; |
728 | 719 | ||
729 | cfg.setGroup("CommandLine"); | 720 | cfg.setGroup("CommandLine"); |
730 | 721 | ||
731 | if (cfg.hasKey("shell_args")) | 722 | if (cfg.hasKey("shell_args")) |
732 | { | 723 | { |
733 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 724 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
734 | for(uint i = 0; i < se_args_list.count(); i++) | 725 | for(uint i = 0; i < se_args_list.count(); i++) |
735 | { | 726 | { |
736 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 727 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
737 | } | 728 | } |
738 | } | 729 | } |
739 | else | 730 | else |
740 | { | 731 | { |
741 | se_args.prepend("--login"); | 732 | se_args.prepend("--login"); |
742 | } | 733 | } |
743 | 734 | ||
744 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 735 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
745 | 736 | ||
746 | // this is the "documentation" for those who know to look | 737 | // this is the "documentation" for those who know to look |
747 | if (! cfg.hasKey("shell_args")) | 738 | if (! cfg.hasKey("shell_args")) |
748 | { | 739 | { |
749 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 740 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
750 | } | 741 | } |
751 | if (! cfg.hasKey("shell_bin")) | 742 | if (! cfg.hasKey("shell_bin")) |
752 | { | 743 | { |
753 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 744 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
754 | } | 745 | } |
755 | 746 | ||
756 | parseCommandLine(); | 747 | parseCommandLine(); |
757 | 748 | ||
758 | // read and apply default values /////////////////////////////////////////// | 749 | // read and apply default values /////////////////////////////////////////// |
759 | resize(321, 321); // Dummy. | 750 | resize(321, 321); // Dummy. |
760 | QSize currentSize = size(); | 751 | QSize currentSize = size(); |
761 | if (currentSize != size()) | 752 | if (currentSize != size()) |
762 | defaultSize = size(); | 753 | defaultSize = size(); |
763 | 754 | ||
764 | 755 | ||
765 | /* allows us to catch cancel/escape */ | 756 | /* allows us to catch cancel/escape */ |
766 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 757 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
767 | QPoint ( 0, 0 )); | 758 | QPoint ( 0, 0 )); |
768 | } | 759 | } |
769 | 760 | ||
770 | void Konsole::show() | 761 | void Konsole::show() |
771 | { | 762 | { |
772 | if ( !nsessions ) | 763 | if ( !nsessions ) |
773 | { | 764 | { |
774 | newSession(); | 765 | newSession(); |
775 | } | 766 | } |
776 | QMainWindow::show(); | 767 | QMainWindow::show(); |
777 | 768 | ||