author | llornkcor <llornkcor> | 2002-04-28 23:08:31 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-28 23:08:31 (UTC) |
commit | 3a7ed24bd010b3313b2260a35c68cfc3b49125b2 (patch) (unidiff) | |
tree | 1e478a7ab2bf05539d6f570db771ccab4d06da81 | |
parent | 28d8806d21ec8fbc806d80614fd496f6b5ca6b55 (diff) | |
download | opie-3a7ed24bd010b3313b2260a35c68cfc3b49125b2.zip opie-3a7ed24bd010b3313b2260a35c68cfc3b49125b2.tar.gz opie-3a7ed24bd010b3313b2260a35c68cfc3b49125b2.tar.bz2 |
debug
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 128 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 1 |
2 files changed, 63 insertions, 66 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 350ab3a..0cd7ed1 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -664,584 +664,580 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) | |||
664 | { | 664 | { |
665 | emit clearSelectionSignal(); | 665 | emit clearSelectionSignal(); |
666 | iPntSel = pntSel = pos; | 666 | iPntSel = pntSel = pos; |
667 | actSel = 1; // left mouse button pressed but nothing selected yet. | 667 | actSel = 1; // left mouse button pressed but nothing selected yet. |
668 | grabMouse( /*crossCursor*/ ); // handle with care! | 668 | grabMouse( /*crossCursor*/ ); // handle with care! |
669 | } | 669 | } |
670 | else | 670 | else |
671 | { | 671 | { |
672 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 672 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
673 | } | 673 | } |
674 | } | 674 | } |
675 | if ( ev->button() == MidButton ) | 675 | if ( ev->button() == MidButton ) |
676 | { | 676 | { |
677 | emitSelection(); | 677 | emitSelection(); |
678 | } | 678 | } |
679 | if ( ev->button() == RightButton ) // Configure | 679 | if ( ev->button() == RightButton ) // Configure |
680 | { | 680 | { |
681 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 681 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 685 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
686 | { | 686 | { |
687 | // for auto-hiding the cursor, we need mouseTracking | 687 | // for auto-hiding the cursor, we need mouseTracking |
688 | if (ev->state() == NoButton ) return; | 688 | if (ev->state() == NoButton ) return; |
689 | 689 | ||
690 | if (actSel == 0) return; | 690 | if (actSel == 0) return; |
691 | 691 | ||
692 | // don't extend selection while pasting | 692 | // don't extend selection while pasting |
693 | if (ev->state() & MidButton) return; | 693 | if (ev->state() & MidButton) return; |
694 | 694 | ||
695 | //if ( !contentsRect().contains(ev->pos()) ) return; | 695 | //if ( !contentsRect().contains(ev->pos()) ) return; |
696 | QPoint tL = contentsRect().topLeft(); | 696 | QPoint tL = contentsRect().topLeft(); |
697 | int tLx = tL.x(); | 697 | int tLx = tL.x(); |
698 | int tLy = tL.y(); | 698 | int tLy = tL.y(); |
699 | int scroll = scrollbar->value(); | 699 | int scroll = scrollbar->value(); |
700 | 700 | ||
701 | // we're in the process of moving the mouse with the left button pressed | 701 | // we're in the process of moving the mouse with the left button pressed |
702 | // the mouse cursor will kept catched within the bounds of the text in | 702 | // the mouse cursor will kept catched within the bounds of the text in |
703 | // this widget. | 703 | // this widget. |
704 | 704 | ||
705 | // Adjust position within text area bounds. See FIXME above. | 705 | // Adjust position within text area bounds. See FIXME above. |
706 | QPoint pos = ev->pos(); | 706 | QPoint pos = ev->pos(); |
707 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 707 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
708 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 708 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
709 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 709 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
710 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 710 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
711 | // check if we produce a mouse move event by this | 711 | // check if we produce a mouse move event by this |
712 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 712 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
713 | 713 | ||
714 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 714 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
715 | { | 715 | { |
716 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 716 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
717 | } | 717 | } |
718 | if ( pos.y() == tLy+bY ) | 718 | if ( pos.y() == tLy+bY ) |
719 | { | 719 | { |
720 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 720 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
721 | } | 721 | } |
722 | 722 | ||
723 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 723 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
724 | QPoint ohere; | 724 | QPoint ohere; |
725 | bool swapping = FALSE; | 725 | bool swapping = FALSE; |
726 | 726 | ||
727 | if ( word_selection_mode ) | 727 | if ( word_selection_mode ) |
728 | { | 728 | { |
729 | // Extend to word boundaries | 729 | // Extend to word boundaries |
730 | int i; | 730 | int i; |
731 | int selClass; | 731 | int selClass; |
732 | 732 | ||
733 | bool left_not_right = ( here.y() < iPntSel.y() || | 733 | bool left_not_right = ( here.y() < iPntSel.y() || |
734 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 734 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
735 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 735 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
736 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 736 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
737 | swapping = left_not_right != old_left_not_right; | 737 | swapping = left_not_right != old_left_not_right; |
738 | 738 | ||
739 | // Find left (left_not_right ? from here : from start) | 739 | // Find left (left_not_right ? from here : from start) |
740 | QPoint left = left_not_right ? here : iPntSel; | 740 | QPoint left = left_not_right ? here : iPntSel; |
741 | i = loc(left.x(),left.y()); | 741 | i = loc(left.x(),left.y()); |
742 | selClass = charClass(image[i].c); | 742 | selClass = charClass(image[i].c); |
743 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 743 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
744 | { i--; left.rx()--; } | 744 | { i--; left.rx()--; } |
745 | 745 | ||
746 | // Find left (left_not_right ? from start : from here) | 746 | // Find left (left_not_right ? from start : from here) |
747 | QPoint right = left_not_right ? iPntSel : here; | 747 | QPoint right = left_not_right ? iPntSel : here; |
748 | i = loc(right.x(),right.y()); | 748 | i = loc(right.x(),right.y()); |
749 | selClass = charClass(image[i].c); | 749 | selClass = charClass(image[i].c); |
750 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 750 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
751 | { i++; right.rx()++; } | 751 | { i++; right.rx()++; } |
752 | 752 | ||
753 | // Pick which is start (ohere) and which is extension (here) | 753 | // Pick which is start (ohere) and which is extension (here) |
754 | if ( left_not_right ) | 754 | if ( left_not_right ) |
755 | { | 755 | { |
756 | here = left; ohere = right; | 756 | here = left; ohere = right; |
757 | } | 757 | } |
758 | else | 758 | else |
759 | { | 759 | { |
760 | here = right; ohere = left; | 760 | here = right; ohere = left; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 764 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
765 | 765 | ||
766 | if ( word_selection_mode ) { | 766 | if ( word_selection_mode ) { |
767 | if ( actSel < 2 || swapping ) { | 767 | if ( actSel < 2 || swapping ) { |
768 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 768 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
769 | } | 769 | } |
770 | } else if ( actSel < 2 ) { | 770 | } else if ( actSel < 2 ) { |
771 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 771 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
772 | } | 772 | } |
773 | 773 | ||
774 | actSel = 2; // within selection | 774 | actSel = 2; // within selection |
775 | pntSel = here; | 775 | pntSel = here; |
776 | emit extendSelectionSignal( here.x(), here.y() ); | 776 | emit extendSelectionSignal( here.x(), here.y() ); |
777 | } | 777 | } |
778 | 778 | ||
779 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 779 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
780 | { | 780 | { |
781 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 781 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
782 | if ( ev->button() == LeftButton) | 782 | if ( ev->button() == LeftButton) |
783 | { | 783 | { |
784 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 784 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
785 | preserve_line_breaks = TRUE; | 785 | preserve_line_breaks = TRUE; |
786 | actSel = 0; | 786 | actSel = 0; |
787 | 787 | ||
788 | //FIXME: emits a release event even if the mouse is | 788 | //FIXME: emits a release event even if the mouse is |
789 | // outside the range. The procedure used in `mouseMoveEvent' | 789 | // outside the range. The procedure used in `mouseMoveEvent' |
790 | // applies here, too. | 790 | // applies here, too. |
791 | 791 | ||
792 | QPoint tL = contentsRect().topLeft(); | 792 | QPoint tL = contentsRect().topLeft(); |
793 | int tLx = tL.x(); | 793 | int tLx = tL.x(); |
794 | int tLy = tL.y(); | 794 | int tLy = tL.y(); |
795 | 795 | ||
796 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 796 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
797 | emit mouseSignal( 3, // release | 797 | emit mouseSignal( 3, // release |
798 | (ev->x()-tLx-blX)/font_w + 1, | 798 | (ev->x()-tLx-blX)/font_w + 1, |
799 | (ev->y()-tLy-bY)/font_h + 1 ); | 799 | (ev->y()-tLy-bY)/font_h + 1 ); |
800 | releaseMouse(); | 800 | releaseMouse(); |
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 804 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
805 | { | 805 | { |
806 | if ( ev->button() != LeftButton) return; | 806 | if ( ev->button() != LeftButton) return; |
807 | 807 | ||
808 | QPoint tL = contentsRect().topLeft(); | 808 | QPoint tL = contentsRect().topLeft(); |
809 | int tLx = tL.x(); | 809 | int tLx = tL.x(); |
810 | int tLy = tL.y(); | 810 | int tLy = tL.y(); |
811 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 811 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
812 | 812 | ||
813 | // pass on double click as two clicks. | 813 | // pass on double click as two clicks. |
814 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 814 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
815 | { | 815 | { |
816 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 816 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
817 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 817 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
818 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 818 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
819 | return; | 819 | return; |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | emit clearSelectionSignal(); | 823 | emit clearSelectionSignal(); |
824 | QPoint bgnSel = pos; | 824 | QPoint bgnSel = pos; |
825 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 825 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
826 | int i = loc(bgnSel.x(),bgnSel.y()); | 826 | int i = loc(bgnSel.x(),bgnSel.y()); |
827 | iPntSel = bgnSel; | 827 | iPntSel = bgnSel; |
828 | 828 | ||
829 | word_selection_mode = TRUE; | 829 | word_selection_mode = TRUE; |
830 | 830 | ||
831 | // find word boundaries... | 831 | // find word boundaries... |
832 | int selClass = charClass(image[i].c); | 832 | int selClass = charClass(image[i].c); |
833 | { | 833 | { |
834 | // set the start... | 834 | // set the start... |
835 | int x = bgnSel.x(); | 835 | int x = bgnSel.x(); |
836 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 836 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
837 | { i--; x--; } | 837 | { i--; x--; } |
838 | bgnSel.setX(x); | 838 | bgnSel.setX(x); |
839 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 839 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
840 | 840 | ||
841 | // set the end... | 841 | // set the end... |
842 | i = loc( endSel.x(), endSel.y() ); | 842 | i = loc( endSel.x(), endSel.y() ); |
843 | x = endSel.x(); | 843 | x = endSel.x(); |
844 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 844 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
845 | { i++; x++ ; } | 845 | { i++; x++ ; } |
846 | endSel.setX(x); | 846 | endSel.setX(x); |
847 | actSel = 2; // within selection | 847 | actSel = 2; // within selection |
848 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 848 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
849 | emit endSelectionSignal(preserve_line_breaks); | 849 | emit endSelectionSignal(preserve_line_breaks); |
850 | preserve_line_breaks = TRUE; | 850 | preserve_line_breaks = TRUE; |
851 | } | 851 | } |
852 | } | 852 | } |
853 | 853 | ||
854 | void TEWidget::focusInEvent( QFocusEvent * ) | 854 | void TEWidget::focusInEvent( QFocusEvent * ) |
855 | { | 855 | { |
856 | |||
856 | // do nothing, to prevent repainting | 857 | // do nothing, to prevent repainting |
857 | } | 858 | } |
858 | 859 | ||
859 | 860 | ||
860 | void TEWidget::focusOutEvent( QFocusEvent * ) | 861 | void TEWidget::focusOutEvent( QFocusEvent * ) |
861 | { | 862 | { |
862 | // do nothing, to prevent repainting | 863 | // do nothing, to prevent repainting |
863 | } | 864 | } |
864 | 865 | ||
865 | bool TEWidget::focusNextPrevChild( bool next ) | 866 | bool TEWidget::focusNextPrevChild( bool next ) |
866 | { | 867 | { |
867 | if (next) | 868 | if (next) |
868 | return false; // This disables changing the active part in konqueror | 869 | return false; // This disables changing the active part in konqueror |
869 | // when pressing Tab | 870 | // when pressing Tab |
870 | return QFrame::focusNextPrevChild( next ); | 871 | return QFrame::focusNextPrevChild( next ); |
871 | } | 872 | } |
872 | 873 | ||
873 | 874 | ||
874 | int TEWidget::charClass(char ch) const | 875 | int TEWidget::charClass(char ch) const |
875 | { | 876 | { |
876 | // This might seem like overkill, but imagine if ch was a Unicode | 877 | // This might seem like overkill, but imagine if ch was a Unicode |
877 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 878 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
878 | // the different language ranges, etc. | 879 | // the different language ranges, etc. |
879 | 880 | ||
880 | if ( isspace(ch) ) return ' '; | 881 | if ( isspace(ch) ) return ' '; |
881 | 882 | ||
882 | static const char *word_characters = ":@-./_~"; | 883 | static const char *word_characters = ":@-./_~"; |
883 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 884 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
884 | return 'a'; | 885 | return 'a'; |
885 | 886 | ||
886 | // Everything else is weird | 887 | // Everything else is weird |
887 | return 1; | 888 | return 1; |
888 | } | 889 | } |
889 | 890 | ||
890 | void TEWidget::setMouseMarks(bool on) | 891 | void TEWidget::setMouseMarks(bool on) |
891 | { | 892 | { |
892 | mouse_marks = on; | 893 | mouse_marks = on; |
893 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 894 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
894 | } | 895 | } |
895 | 896 | ||
896 | /* ------------------------------------------------------------------------- */ | 897 | /* ------------------------------------------------------------------------- */ |
897 | /* */ | 898 | /* */ |
898 | /* Clipboard */ | 899 | /* Clipboard */ |
899 | /* */ | 900 | /* */ |
900 | /* ------------------------------------------------------------------------- */ | 901 | /* ------------------------------------------------------------------------- */ |
901 | 902 | ||
902 | #undef KeyPress | 903 | #undef KeyPress |
903 | 904 | ||
904 | void TEWidget::emitSelection() | 905 | void TEWidget::emitSelection() |
905 | // Paste Clipboard by simulating keypress events | 906 | // Paste Clipboard by simulating keypress events |
906 | { | 907 | { |
907 | #ifndef QT_NO_CLIPBOARD | 908 | #ifndef QT_NO_CLIPBOARD |
908 | QString text = QApplication::clipboard()->text(); | 909 | QString text = QApplication::clipboard()->text(); |
909 | if ( ! text.isNull() ) | 910 | if ( ! text.isNull() ) |
910 | { | 911 | { |
911 | text.replace(QRegExp("\n"), "\r"); | 912 | text.replace(QRegExp("\n"), "\r"); |
912 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 913 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
913 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 914 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
914 | emit clearSelectionSignal(); | 915 | emit clearSelectionSignal(); |
915 | } | 916 | } |
916 | #endif | 917 | #endif |
917 | } | 918 | } |
918 | 919 | ||
919 | void TEWidget::emitText(QString text) | 920 | void TEWidget::emitText(QString text) |
920 | { | 921 | { |
921 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 922 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
922 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 923 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
923 | } | 924 | } |
924 | 925 | ||
925 | void TEWidget::pasteClipboard( ) | 926 | void TEWidget::pasteClipboard( ) |
926 | { | 927 | { |
927 | emitSelection(); | 928 | emitSelection(); |
928 | } | 929 | } |
929 | 930 | ||
930 | void TEWidget::setSelection(const QString& t) | 931 | void TEWidget::setSelection(const QString& t) |
931 | { | 932 | { |
932 | #ifndef QT_NO_CLIPBOARD | 933 | #ifndef QT_NO_CLIPBOARD |
933 | // Disconnect signal while WE set the clipboard | 934 | // Disconnect signal while WE set the clipboard |
934 | QObject *cb = QApplication::clipboard(); | 935 | QObject *cb = QApplication::clipboard(); |
935 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 936 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
936 | this, SLOT(onClearSelection()) ); | 937 | this, SLOT(onClearSelection()) ); |
937 | 938 | ||
938 | QApplication::clipboard()->setText(t); | 939 | QApplication::clipboard()->setText(t); |
939 | 940 | ||
940 | QObject::connect( cb, SIGNAL(dataChanged()), | 941 | QObject::connect( cb, SIGNAL(dataChanged()), |
941 | this, SLOT(onClearSelection()) ); | 942 | this, SLOT(onClearSelection()) ); |
942 | #endif | 943 | #endif |
943 | } | 944 | } |
944 | 945 | ||
945 | void TEWidget::onClearSelection() | 946 | void TEWidget::onClearSelection() |
946 | { | 947 | { |
947 | emit clearSelectionSignal(); | 948 | emit clearSelectionSignal(); |
948 | } | 949 | } |
949 | 950 | ||
950 | /* ------------------------------------------------------------------------- */ | 951 | /* ------------------------------------------------------------------------- */ |
951 | /* */ | 952 | /* */ |
952 | /* Keyboard */ | 953 | /* Keyboard */ |
953 | /* */ | 954 | /* */ |
954 | /* ------------------------------------------------------------------------- */ | 955 | /* ------------------------------------------------------------------------- */ |
955 | 956 | ||
956 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 957 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
957 | // due to a bug in `QT' or the ignorance of the author to prevent | 958 | // due to a bug in `QT' or the ignorance of the author to prevent |
958 | // repaint events being emitted to the screen whenever one leaves | 959 | // repaint events being emitted to the screen whenever one leaves |
959 | // or reenters the screen to/from another application. | 960 | // or reenters the screen to/from another application. |
960 | // | 961 | // |
961 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 962 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
962 | // which would also let you have an in-focus cursor and an out-focus | 963 | // which would also let you have an in-focus cursor and an out-focus |
963 | // cursor like xterm does. | 964 | // cursor like xterm does. |
964 | 965 | ||
965 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 966 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
966 | // focusOutEvent() so that update() isn't called. | 967 | // focusOutEvent() so that update() isn't called. |
967 | // For auto-hide, we need to get keypress-events, but we only get them when | 968 | // For auto-hide, we need to get keypress-events, but we only get them when |
968 | // we have focus. | 969 | // we have focus. |
969 | 970 | ||
970 | void TEWidget::doScroll(int lines) | 971 | void TEWidget::doScroll(int lines) |
971 | { | 972 | { |
972 | scrollbar->setValue(scrollbar->value()+lines); | 973 | scrollbar->setValue(scrollbar->value()+lines); |
973 | } | 974 | } |
974 | 975 | ||
975 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 976 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
976 | { | 977 | { |
977 | if ( (e->type() == QEvent::Accel || | 978 | if ( (e->type() == QEvent::Accel || |
978 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) | 979 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
979 | { | 980 | static_cast<QKeyEvent *>( e )->ignore(); |
980 | static_cast<QKeyEvent *>( e )->ignore(); | 981 | return true; |
981 | return true; | 982 | } |
982 | } | 983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
983 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 984 | return FALSE; // not us |
984 | return FALSE; // not us | 985 | if ( e->type() == QEvent::Wheel) { |
985 | if ( e->type() == QEvent::Wheel) | 986 | QApplication::sendEvent(scrollbar, e); |
986 | { | 987 | } |
987 | QApplication::sendEvent(scrollbar, e); | ||
988 | } | ||
989 | 988 | ||
990 | #ifdef FAKE_CTRL_AND_ALT | 989 | #ifdef FAKE_CTRL_AND_ALT |
991 | static bool control = FALSE; | 990 | static bool control = FALSE; |
992 | static bool alt = FALSE; | 991 | static bool alt = FALSE; |
993 | qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 992 | qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
994 | bool dele=FALSE; | 993 | bool dele=FALSE; |
995 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 994 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
996 | QKeyEvent* ke = (QKeyEvent*)e; | 995 | QKeyEvent* ke = (QKeyEvent*)e; |
997 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 996 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
998 | switch (ke->key()) { | 997 | switch (ke->key()) { |
999 | case Key_F9: // let this be "Control" | 998 | case Key_F9: // let this be "Control" |
1000 | control = keydown; | 999 | control = keydown; |
1001 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1000 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1002 | dele=TRUE; | 1001 | dele=TRUE; |
1003 | break; | 1002 | break; |
1004 | case Key_F13: // let this be "Alt" | 1003 | case Key_F13: // let this be "Alt" |
1005 | alt = keydown; | 1004 | alt = keydown; |
1006 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1005 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1007 | dele=TRUE; | 1006 | dele=TRUE; |
1008 | break; | 1007 | break; |
1009 | default: | 1008 | default: |
1010 | if ( control ) { | 1009 | if ( control ) { |
1011 | int a = toupper(ke->ascii())-64; | 1010 | int a = toupper(ke->ascii())-64; |
1012 | if ( a >= 0 && a < ' ' ) { | 1011 | if ( a >= 0 && a < ' ' ) { |
1013 | e = new QKeyEvent(e->type(), ke->key(), | 1012 | e = new QKeyEvent(e->type(), ke->key(), |
1014 | a, ke->state()|ControlButton, QChar(a,0)); | 1013 | a, ke->state()|ControlButton, QChar(a,0)); |
1015 | dele=TRUE; | 1014 | dele=TRUE; |
1015 | } | ||
1016 | } | ||
1017 | if ( alt ) { | ||
1018 | e = new QKeyEvent(e->type(), ke->key(), | ||
1019 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
1020 | dele=TRUE; | ||
1021 | } | ||
1016 | } | 1022 | } |
1017 | } | 1023 | } |
1018 | if ( alt ) { | ||
1019 | e = new QKeyEvent(e->type(), ke->key(), | ||
1020 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
1021 | dele=TRUE; | ||
1022 | } | ||
1023 | } | ||
1024 | } | ||
1025 | #endif | 1024 | #endif |
1026 | 1025 | ||
1027 | if ( e->type() == QEvent::KeyPress ) | 1026 | if ( e->type() == QEvent::KeyPress ) { |
1028 | { | 1027 | QKeyEvent* ke = (QKeyEvent*)e; |
1029 | QKeyEvent* ke = (QKeyEvent*)e; | 1028 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1030 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1029 | // know where the current selection is. |
1031 | // know where the current selection is. | 1030 | |
1032 | 1031 | qDebug("key pressed is 0x%x",ke->key()); | |
1033 | // qDebug("key pressed is 0x%x",ke->key()); | 1032 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
1034 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1033 | qDebug("key pressed 2 is 0x%x",ke->key()); |
1035 | // qDebug("key pressed 2 is 0x%x",ke->key()); | 1034 | emitText("\\"); // expose |
1036 | emitText("\\"); // expose | 1035 | } else |
1037 | } else | 1036 | emit keyPressedSignal(ke); // expose |
1038 | emit keyPressedSignal(ke); // expose | 1037 | ke->accept(); |
1039 | ke->accept(); | ||
1040 | #ifdef FAKE_CTRL_AND_ALT | 1038 | #ifdef FAKE_CTRL_AND_ALT |
1041 | if ( dele ) delete e; | 1039 | if ( dele ) delete e; |
1042 | #endif | 1040 | #endif |
1043 | return true; // stop the event | 1041 | return true; // stop the event |
1044 | } | 1042 | } |
1045 | if ( e->type() == QEvent::Enter ) | 1043 | if ( e->type() == QEvent::Enter ) { |
1046 | { | 1044 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1047 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1045 | this, SLOT(onClearSelection()) ); |
1048 | this, SLOT(onClearSelection()) ); | 1046 | } |
1049 | } | 1047 | if ( e->type() == QEvent::Leave ) { |
1050 | if ( e->type() == QEvent::Leave ) | 1048 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1051 | { | 1049 | this, SLOT(onClearSelection()) ); |
1052 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1050 | } |
1053 | this, SLOT(onClearSelection()) ); | 1051 | return QFrame::eventFilter( obj, e ); |
1054 | } | ||
1055 | return QFrame::eventFilter( obj, e ); | ||
1056 | } | 1052 | } |
1057 | 1053 | ||
1058 | /* ------------------------------------------------------------------------- */ | 1054 | /* ------------------------------------------------------------------------- */ |
1059 | /* */ | 1055 | /* */ |
1060 | /* Frame */ | 1056 | /* Frame */ |
1061 | /* */ | 1057 | /* */ |
1062 | /* ------------------------------------------------------------------------- */ | 1058 | /* ------------------------------------------------------------------------- */ |
1063 | 1059 | ||
1064 | void TEWidget::frameChanged() | 1060 | void TEWidget::frameChanged() |
1065 | { | 1061 | { |
1066 | propagateSize(); | 1062 | propagateSize(); |
1067 | update(); | 1063 | update(); |
1068 | } | 1064 | } |
1069 | 1065 | ||
1070 | /* ------------------------------------------------------------------------- */ | 1066 | /* ------------------------------------------------------------------------- */ |
1071 | /* */ | 1067 | /* */ |
1072 | /* Sound */ | 1068 | /* Sound */ |
1073 | /* */ | 1069 | /* */ |
1074 | /* ------------------------------------------------------------------------- */ | 1070 | /* ------------------------------------------------------------------------- */ |
1075 | 1071 | ||
1076 | void TEWidget::Bell() | 1072 | void TEWidget::Bell() |
1077 | { | 1073 | { |
1078 | QApplication::beep(); | 1074 | QApplication::beep(); |
1079 | } | 1075 | } |
1080 | 1076 | ||
1081 | /* ------------------------------------------------------------------------- */ | 1077 | /* ------------------------------------------------------------------------- */ |
1082 | /* */ | 1078 | /* */ |
1083 | /* Auxiluary */ | 1079 | /* Auxiluary */ |
1084 | /* */ | 1080 | /* */ |
1085 | /* ------------------------------------------------------------------------- */ | 1081 | /* ------------------------------------------------------------------------- */ |
1086 | 1082 | ||
1087 | void TEWidget::clearImage() | 1083 | void TEWidget::clearImage() |
1088 | // initialize the image | 1084 | // initialize the image |
1089 | // for internal use only | 1085 | // for internal use only |
1090 | { | 1086 | { |
1091 | for (int y = 0; y < lines; y++) | 1087 | for (int y = 0; y < lines; y++) |
1092 | for (int x = 0; x < columns; x++) | 1088 | for (int x = 0; x < columns; x++) |
1093 | { | 1089 | { |
1094 | image[loc(x,y)].c = 0xff; //' '; | 1090 | image[loc(x,y)].c = 0xff; //' '; |
1095 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1091 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1096 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1092 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1097 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1093 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1098 | } | 1094 | } |
1099 | } | 1095 | } |
1100 | 1096 | ||
1101 | // Create Image /////////////////////////////////////////////////////// | 1097 | // Create Image /////////////////////////////////////////////////////// |
1102 | 1098 | ||
1103 | void TEWidget::calcGeometry() | 1099 | void TEWidget::calcGeometry() |
1104 | { | 1100 | { |
1105 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1101 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1106 | 1102 | ||
1107 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1103 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1108 | contentsRect().height()); | 1104 | contentsRect().height()); |
1109 | switch(scrollLoc) | 1105 | switch(scrollLoc) |
1110 | { | 1106 | { |
1111 | case SCRNONE : | 1107 | case SCRNONE : |
1112 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1108 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1113 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1109 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1114 | brX = blX; | 1110 | brX = blX; |
1115 | scrollbar->hide(); | 1111 | scrollbar->hide(); |
1116 | break; | 1112 | break; |
1117 | case SCRLEFT : | 1113 | case SCRLEFT : |
1118 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1114 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1119 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1115 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1120 | blX = brX + scrollbar->width(); | 1116 | blX = brX + scrollbar->width(); |
1121 | scrollbar->move(contentsRect().topLeft()); | 1117 | scrollbar->move(contentsRect().topLeft()); |
1122 | scrollbar->show(); | 1118 | scrollbar->show(); |
1123 | break; | 1119 | break; |
1124 | case SCRRIGHT: | 1120 | case SCRRIGHT: |
1125 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1126 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1122 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1127 | brX = blX; | 1123 | brX = blX; |
1128 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1124 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1129 | scrollbar->show(); | 1125 | scrollbar->show(); |
1130 | break; | 1126 | break; |
1131 | } | 1127 | } |
1132 | //FIXME: support 'rounding' styles | 1128 | //FIXME: support 'rounding' styles |
1133 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1129 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1134 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1130 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1135 | } | 1131 | } |
1136 | 1132 | ||
1137 | void TEWidget::makeImage() | 1133 | void TEWidget::makeImage() |
1138 | //FIXME: rename 'calcGeometry? | 1134 | //FIXME: rename 'calcGeometry? |
1139 | { | 1135 | { |
1140 | calcGeometry(); | 1136 | calcGeometry(); |
1141 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1137 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1142 | clearImage(); | 1138 | clearImage(); |
1143 | } | 1139 | } |
1144 | 1140 | ||
1145 | // calculate the needed size | 1141 | // calculate the needed size |
1146 | QSize TEWidget::calcSize(int cols, int lins) const | 1142 | QSize TEWidget::calcSize(int cols, int lins) const |
1147 | { | 1143 | { |
1148 | int frw = width() - contentsRect().width(); | 1144 | int frw = width() - contentsRect().width(); |
1149 | int frh = height() - contentsRect().height(); | 1145 | int frh = height() - contentsRect().height(); |
1150 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1146 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1151 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1147 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1152 | } | 1148 | } |
1153 | 1149 | ||
1154 | QSize TEWidget::sizeHint() const | 1150 | QSize TEWidget::sizeHint() const |
1155 | { | 1151 | { |
1156 | return size(); | 1152 | return size(); |
1157 | } | 1153 | } |
1158 | 1154 | ||
1159 | void TEWidget::styleChange(QStyle &) | 1155 | void TEWidget::styleChange(QStyle &) |
1160 | { | 1156 | { |
1161 | propagateSize(); | 1157 | propagateSize(); |
1162 | } | 1158 | } |
1163 | 1159 | ||
1164 | #ifndef QT_NO_DRAGANDDROP | 1160 | #ifndef QT_NO_DRAGANDDROP |
1165 | 1161 | ||
1166 | /* --------------------------------------------------------------------- */ | 1162 | /* --------------------------------------------------------------------- */ |
1167 | /* */ | 1163 | /* */ |
1168 | /* Drag & Drop */ | 1164 | /* Drag & Drop */ |
1169 | /* */ | 1165 | /* */ |
1170 | /* --------------------------------------------------------------------- */ | 1166 | /* --------------------------------------------------------------------- */ |
1171 | 1167 | ||
1172 | 1168 | ||
1173 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1169 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1174 | { | 1170 | { |
1175 | e->accept(QTextDrag::canDecode(e) || | 1171 | e->accept(QTextDrag::canDecode(e) || |
1176 | QUriDrag::canDecode(e)); | 1172 | QUriDrag::canDecode(e)); |
1177 | } | 1173 | } |
1178 | 1174 | ||
1179 | void TEWidget::dropEvent(QDropEvent* event) | 1175 | void TEWidget::dropEvent(QDropEvent* event) |
1180 | { | 1176 | { |
1181 | // The current behaviour when url(s) are dropped is | 1177 | // The current behaviour when url(s) are dropped is |
1182 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1178 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1183 | // * in all other cases, just paste | 1179 | // * in all other cases, just paste |
1184 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1180 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1185 | QStrList strlist; | 1181 | QStrList strlist; |
1186 | int file_count = 0; | 1182 | int file_count = 0; |
1187 | dropText = ""; | 1183 | dropText = ""; |
1188 | bool bPopup = true; | 1184 | bool bPopup = true; |
1189 | 1185 | ||
1190 | if(QUriDrag::decode(event, strlist)) { | 1186 | if(QUriDrag::decode(event, strlist)) { |
1191 | if (strlist.count()) { | 1187 | if (strlist.count()) { |
1192 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1188 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1193 | if(file_count++ > 0) { | 1189 | if(file_count++ > 0) { |
1194 | dropText += " "; | 1190 | dropText += " "; |
1195 | bPopup = false; // more than one file, don't popup | 1191 | bPopup = false; // more than one file, don't popup |
1196 | } | 1192 | } |
1197 | 1193 | ||
1198 | /* | 1194 | /* |
1199 | KURL url(p); | 1195 | KURL url(p); |
1200 | if (url.isLocalFile()) { | 1196 | if (url.isLocalFile()) { |
1201 | dropText += url.path(); // local URL : remove protocol | 1197 | dropText += url.path(); // local URL : remove protocol |
1202 | } | 1198 | } |
1203 | else { | 1199 | else { |
1204 | dropText += url.prettyURL(); | 1200 | dropText += url.prettyURL(); |
1205 | bPopup = false; // a non-local file, don't popup | 1201 | bPopup = false; // a non-local file, don't popup |
1206 | } | 1202 | } |
1207 | */ | 1203 | */ |
1208 | 1204 | ||
1209 | } | 1205 | } |
1210 | 1206 | ||
1211 | if (bPopup) | 1207 | if (bPopup) |
1212 | // m_drop->popup(pos() + event->pos()); | 1208 | // m_drop->popup(pos() + event->pos()); |
1213 | m_drop->popup(mapToGlobal(event->pos())); | 1209 | m_drop->popup(mapToGlobal(event->pos())); |
1214 | else | 1210 | else |
1215 | { | 1211 | { |
1216 | if (currentSession) { | 1212 | if (currentSession) { |
1217 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1213 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1218 | } | 1214 | } |
1219 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1215 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1220 | } | 1216 | } |
1221 | } | 1217 | } |
1222 | } | 1218 | } |
1223 | else if(QTextDrag::decode(event, dropText)) { | 1219 | else if(QTextDrag::decode(event, dropText)) { |
1224 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1220 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1225 | if (currentSession) { | 1221 | if (currentSession) { |
1226 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1222 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1227 | } | 1223 | } |
1228 | // Paste it | 1224 | // Paste it |
1229 | } | 1225 | } |
1230 | } | 1226 | } |
1231 | #endif | 1227 | #endif |
1232 | 1228 | ||
1233 | 1229 | ||
1234 | void TEWidget::drop_menu_activated(int item) | 1230 | void TEWidget::drop_menu_activated(int item) |
1235 | { | 1231 | { |
1236 | #ifndef QT_NO_DRAGANDDROP | 1232 | #ifndef QT_NO_DRAGANDDROP |
1237 | switch (item) | 1233 | switch (item) |
1238 | { | 1234 | { |
1239 | case 0: // paste | 1235 | case 0: // paste |
1240 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1236 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1241 | // KWM::activate((Window)this->winId()); | 1237 | // KWM::activate((Window)this->winId()); |
1242 | break; | 1238 | break; |
1243 | case 1: // cd ... | 1239 | case 1: // cd ... |
1244 | currentSession->getEmulation()->sendString("cd "); | 1240 | currentSession->getEmulation()->sendString("cd "); |
1245 | struct stat statbuf; | 1241 | struct stat statbuf; |
1246 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1242 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1247 | { | 1243 | { |
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index e3ba346..b3c0453 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp | |||
@@ -1,60 +1,61 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole, an X terminal. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include "konsole.h" | 22 | #include "konsole.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | 32 | ||
33 | /* --| main |------------------------------------------------------ */ | 33 | /* --| main |------------------------------------------------------ */ |
34 | int main(int argc, char* argv[]) | 34 | int main(int argc, char* argv[]) |
35 | { | 35 | { |
36 | setuid(getuid()); setgid(getgid()); // drop privileges | 36 | setuid(getuid()); setgid(getgid()); // drop privileges |
37 | 37 | ||
38 | QPEApplication a( argc, argv ); | 38 | QPEApplication a( argc, argv ); |
39 | 39 | ||
40 | #ifdef FAKE_CTRL_AND_ALT | 40 | #ifdef FAKE_CTRL_AND_ALT |
41 | qDebug("Fake Ctrl and Alt defined"); | ||
41 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 42 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | QStrList tmp; | 45 | QStrList tmp; |
45 | const char* shell = getenv("SHELL"); | 46 | const char* shell = getenv("SHELL"); |
46 | if (shell == NULL || *shell == '\0') | 47 | if (shell == NULL || *shell == '\0') |
47 | shell = "/bin/sh"; | 48 | shell = "/bin/sh"; |
48 | 49 | ||
49 | // sh is completely broken on familiar. Let's try to get something better | 50 | // sh is completely broken on familiar. Let's try to get something better |
50 | if ( qstrcmp( shell, "/bin/shell" ) == 0 && QFile::exists( "/bin/bash" ) ) | 51 | if ( qstrcmp( shell, "/bin/shell" ) == 0 && QFile::exists( "/bin/bash" ) ) |
51 | shell = "/bin/bash"; | 52 | shell = "/bin/bash"; |
52 | 53 | ||
53 | putenv((char*)"COLORTERM="); // to trigger mc's color detection | 54 | putenv((char*)"COLORTERM="); // to trigger mc's color detection |
54 | 55 | ||
55 | Konsole m( "test", shell, tmp, TRUE ); | 56 | Konsole m( "test", shell, tmp, TRUE ); |
56 | m.setCaption( Konsole::tr("Terminal") ); | 57 | m.setCaption( Konsole::tr("Terminal") ); |
57 | a.showMainWidget( &m ); | 58 | a.showMainWidget( &m ); |
58 | 59 | ||
59 | return a.exec(); | 60 | return a.exec(); |
60 | } | 61 | } |