summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp4
-rw-r--r--noncore/apps/opie-console/TEWidget.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index 3d010cb..444924b 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -867,498 +867,498 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
867 return; 867 return;
868 } 868 }
869 869
870 870
871 emit clearSelectionSignal(); 871 emit clearSelectionSignal();
872 QPoint bgnSel = pos; 872 QPoint bgnSel = pos;
873 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 873 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
874 int i = loc(bgnSel.x(),bgnSel.y()); 874 int i = loc(bgnSel.x(),bgnSel.y());
875 iPntSel = bgnSel; 875 iPntSel = bgnSel;
876 876
877 word_selection_mode = TRUE; 877 word_selection_mode = TRUE;
878 878
879 // find word boundaries... 879 // find word boundaries...
880 int selClass = charClass(image[i].c); 880 int selClass = charClass(image[i].c);
881 { 881 {
882 // set the start... 882 // set the start...
883 int x = bgnSel.x(); 883 int x = bgnSel.x();
884 while ( x > 0 && charClass(image[i-1].c) == selClass ) 884 while ( x > 0 && charClass(image[i-1].c) == selClass )
885 { i--; x--; } 885 { i--; x--; }
886 bgnSel.setX(x); 886 bgnSel.setX(x);
887 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 887 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
888 888
889 // set the end... 889 // set the end...
890 i = loc( endSel.x(), endSel.y() ); 890 i = loc( endSel.x(), endSel.y() );
891 x = endSel.x(); 891 x = endSel.x();
892 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 892 while( x < columns-1 && charClass(image[i+1].c) == selClass )
893 { i++; x++ ; } 893 { i++; x++ ; }
894 endSel.setX(x); 894 endSel.setX(x);
895 actSel = 2; // within selection 895 actSel = 2; // within selection
896 emit extendSelectionSignal( endSel.x(), endSel.y() ); 896 emit extendSelectionSignal( endSel.x(), endSel.y() );
897 emit endSelectionSignal(preserve_line_breaks); 897 emit endSelectionSignal(preserve_line_breaks);
898 preserve_line_breaks = TRUE; 898 preserve_line_breaks = TRUE;
899 } 899 }
900} 900}
901 901
902void TEWidget::focusInEvent( QFocusEvent * ) 902void TEWidget::focusInEvent( QFocusEvent * )
903{ 903{
904 904
905 // do nothing, to prevent repainting 905 // do nothing, to prevent repainting
906} 906}
907 907
908 908
909void TEWidget::focusOutEvent( QFocusEvent * ) 909void TEWidget::focusOutEvent( QFocusEvent * )
910{ 910{
911 // do nothing, to prevent repainting 911 // do nothing, to prevent repainting
912} 912}
913 913
914bool TEWidget::focusNextPrevChild( bool next ) 914bool TEWidget::focusNextPrevChild( bool next )
915{ 915{
916 if (next) 916 if (next)
917 return false; // This disables changing the active part in konqueror 917 return false; // This disables changing the active part in konqueror
918 // when pressing Tab 918 // when pressing Tab
919 return QFrame::focusNextPrevChild( next ); 919 return QFrame::focusNextPrevChild( next );
920} 920}
921 921
922 922
923int TEWidget::charClass(char ch) const 923int TEWidget::charClass(char ch) const
924{ 924{
925 // This might seem like overkill, but imagine if ch was a Unicode 925 // This might seem like overkill, but imagine if ch was a Unicode
926 // character (Qt 2.0 QChar) - it might then be sensible to separate 926 // character (Qt 2.0 QChar) - it might then be sensible to separate
927 // the different language ranges, etc. 927 // the different language ranges, etc.
928 928
929 if ( isspace(ch) ) return ' '; 929 if ( isspace(ch) ) return ' ';
930 930
931 static const char *word_characters = ":@-./_~"; 931 static const char *word_characters = ":@-./_~";
932 if ( isalnum(ch) || strchr(word_characters, ch) ) 932 if ( isalnum(ch) || strchr(word_characters, ch) )
933 return 'a'; 933 return 'a';
934 934
935 // Everything else is weird 935 // Everything else is weird
936 return 1; 936 return 1;
937} 937}
938 938
939void TEWidget::setMouseMarks(bool on) 939void TEWidget::setMouseMarks(bool on)
940{ 940{
941 mouse_marks = on; 941 mouse_marks = on;
942 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 942 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
943} 943}
944 944
945/* ------------------------------------------------------------------------- */ 945/* ------------------------------------------------------------------------- */
946/* */ 946/* */
947/* Clipboard */ 947/* Clipboard */
948/* */ 948/* */
949/* ------------------------------------------------------------------------- */ 949/* ------------------------------------------------------------------------- */
950 950
951#undef KeyPress 951#undef KeyPress
952 952
953void TEWidget::emitSelection() 953void TEWidget::emitSelection()
954// Paste Clipboard by simulating keypress events 954// Paste Clipboard by simulating keypress events
955{ 955{
956#ifndef QT_NO_CLIPBOARD 956#ifndef QT_NO_CLIPBOARD
957 QString text = QApplication::clipboard()->text(); 957 QString text = QApplication::clipboard()->text();
958 if ( ! text.isNull() ) 958 if ( ! text.isNull() )
959 { 959 {
960 text.replace(QRegExp("\n"), "\r"); 960 text.replace(QRegExp("\n"), "\r");
961 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 961 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
962 emit keyPressedSignal(&e); // expose as a big fat keypress event 962 emit keyPressedSignal(&e); // expose as a big fat keypress event
963 emit clearSelectionSignal(); 963 emit clearSelectionSignal();
964 } 964 }
965#endif 965#endif
966} 966}
967 967
968void TEWidget::emitText(QString text) 968void TEWidget::emitText(QString text)
969{ 969{
970 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 970 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
971 emit keyPressedSignal(&e); // expose as a big fat keypress event 971 emit keyPressedSignal(&e); // expose as a big fat keypress event
972} 972}
973 973
974void TEWidget::pasteClipboard( ) 974void TEWidget::pasteClipboard( )
975{ 975{
976 emitSelection(); 976 emitSelection();
977} 977}
978 978
979void TEWidget::setSelection(const QString& t) 979void TEWidget::setSelection(const QString& t)
980{ 980{
981#ifndef QT_NO_CLIPBOARD 981#ifndef QT_NO_CLIPBOARD
982 // Disconnect signal while WE set the clipboard 982 // Disconnect signal while WE set the clipboard
983 QObject *cb = QApplication::clipboard(); 983 QObject *cb = QApplication::clipboard();
984 QObject::disconnect( cb, SIGNAL(dataChanged()), 984 QObject::disconnect( cb, SIGNAL(dataChanged()),
985 this, SLOT(onClearSelection()) ); 985 this, SLOT(onClearSelection()) );
986 986
987 QApplication::clipboard()->setText(t); 987 QApplication::clipboard()->setText(t);
988 988
989 QObject::connect( cb, SIGNAL(dataChanged()), 989 QObject::connect( cb, SIGNAL(dataChanged()),
990 this, SLOT(onClearSelection()) ); 990 this, SLOT(onClearSelection()) );
991#endif 991#endif
992} 992}
993 993
994void TEWidget::onClearSelection() 994void TEWidget::onClearSelection()
995{ 995{
996 emit clearSelectionSignal(); 996 emit clearSelectionSignal();
997} 997}
998 998
999/* ------------------------------------------------------------------------- */ 999/* ------------------------------------------------------------------------- */
1000/* */ 1000/* */
1001/* Keyboard */ 1001/* Keyboard */
1002/* */ 1002/* */
1003/* ------------------------------------------------------------------------- */ 1003/* ------------------------------------------------------------------------- */
1004 1004
1005//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 1005//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
1006// due to a bug in `QT' or the ignorance of the author to prevent 1006// due to a bug in `QT' or the ignorance of the author to prevent
1007// repaint events being emitted to the screen whenever one leaves 1007// repaint events being emitted to the screen whenever one leaves
1008// or reenters the screen to/from another application. 1008// or reenters the screen to/from another application.
1009// 1009//
1010// Troll says one needs to change focusInEvent() and focusOutEvent(), 1010// Troll says one needs to change focusInEvent() and focusOutEvent(),
1011// which would also let you have an in-focus cursor and an out-focus 1011// which would also let you have an in-focus cursor and an out-focus
1012// cursor like xterm does. 1012// cursor like xterm does.
1013 1013
1014// for the auto-hide cursor feature, I added empty focusInEvent() and 1014// for the auto-hide cursor feature, I added empty focusInEvent() and
1015// focusOutEvent() so that update() isn't called. 1015// focusOutEvent() so that update() isn't called.
1016// For auto-hide, we need to get keypress-events, but we only get them when 1016// For auto-hide, we need to get keypress-events, but we only get them when
1017// we have focus. 1017// we have focus.
1018 1018
1019void TEWidget::doScroll(int lines) 1019void TEWidget::doScroll(int lines)
1020{ 1020{
1021 scrollbar->setValue(scrollbar->value()+lines); 1021 scrollbar->setValue(scrollbar->value()+lines);
1022} 1022}
1023 1023
1024bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1024bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1025{ 1025{
1026 if ( (e->type() == QEvent::Accel || 1026 if ( (e->type() == QEvent::Accel ||
1027 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1027 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1028 static_cast<QKeyEvent *>( e )->ignore(); 1028 static_cast<QKeyEvent *>( e )->ignore();
1029 return true; 1029 return true;
1030 } 1030 }
1031 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1031 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1032 return FALSE; // not us 1032 return FALSE; // not us
1033 if ( e->type() == QEvent::Wheel) { 1033 if ( e->type() == QEvent::Wheel) {
1034 QApplication::sendEvent(scrollbar, e); 1034 QApplication::sendEvent(scrollbar, e);
1035 } 1035 }
1036 1036
1037#ifdef FAKE_CTRL_AND_ALT 1037#ifdef FAKE_CTRL_AND_ALT
1038 static bool control = FALSE; 1038 static bool control = FALSE;
1039 static bool alt = FALSE; 1039 static bool alt = FALSE;
1040// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1040// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1041 bool dele=FALSE; 1041 bool dele=FALSE;
1042 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1042 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1043 QKeyEvent* ke = (QKeyEvent*)e; 1043 QKeyEvent* ke = (QKeyEvent*)e;
1044 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1044 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1045 switch (ke->key()) { 1045 switch (ke->key()) {
1046 case Key_F9: // let this be "Control" 1046 case Key_F9: // let this be "Control"
1047 control = keydown; 1047 control = keydown;
1048 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1048 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1049 dele=TRUE; 1049 dele=TRUE;
1050 break; 1050 break;
1051 case Key_F13: // let this be "Alt" 1051 case Key_F13: // let this be "Alt"
1052 alt = keydown; 1052 alt = keydown;
1053 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1053 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1054 dele=TRUE; 1054 dele=TRUE;
1055 break; 1055 break;
1056 default: 1056 default:
1057 if ( control ) { 1057 if ( control ) {
1058 int a = toupper(ke->ascii())-64; 1058 int a = toupper(ke->ascii())-64;
1059 if ( a >= 0 && a < ' ' ) { 1059 if ( a >= 0 && a < ' ' ) {
1060 e = new QKeyEvent(e->type(), ke->key(), 1060 e = new QKeyEvent(e->type(), ke->key(),
1061 a, ke->state()|ControlButton, QChar(a,0)); 1061 a, ke->state()|ControlButton, QChar(a,0));
1062 dele=TRUE; 1062 dele=TRUE;
1063 } 1063 }
1064 } 1064 }
1065 if ( alt ) { 1065 if ( alt ) {
1066 e = new QKeyEvent(e->type(), ke->key(), 1066 e = new QKeyEvent(e->type(), ke->key(),
1067 ke->ascii(), ke->state()|AltButton, ke->text()); 1067 ke->ascii(), ke->state()|AltButton, ke->text());
1068 dele=TRUE; 1068 dele=TRUE;
1069 } 1069 }
1070 } 1070 }
1071 } 1071 }
1072#endif 1072#endif
1073 1073
1074 if ( e->type() == QEvent::KeyPress ) { 1074 if ( e->type() == QEvent::KeyPress ) {
1075 QKeyEvent* ke = (QKeyEvent*)e; 1075 QKeyEvent* ke = (QKeyEvent*)e;
1076 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1076 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1077 // know where the current selection is. 1077 // know where the current selection is.
1078 1078
1079// qDebug("key pressed is 0x%x",ke->key()); 1079// qDebug("key pressed is 0x%x",ke->key());
1080 1080
1081 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1081 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1082 1082
1083// qDebug("key pressed 2 is 0x%x",ke->key()); 1083// qDebug("key pressed 2 is 0x%x",ke->key());
1084 emitText("\\"); // expose 1084 emitText("\\"); // expose
1085 } else 1085 } else
1086 emit keyPressedSignal(ke); // expose 1086 emit keyPressedSignal(ke); // expose
1087 ke->accept(); 1087 ke->accept();
1088#ifdef FAKE_CTRL_AND_ALT 1088#ifdef FAKE_CTRL_AND_ALT
1089 if ( dele ) delete e; 1089 if ( dele ) delete e;
1090#endif 1090#endif
1091 return true; // stop the event 1091 return true; // stop the event
1092 } 1092 }
1093 if ( e->type() == QEvent::Enter ) { 1093 if ( e->type() == QEvent::Enter ) {
1094 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1094 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1095 this, SLOT(onClearSelection()) ); 1095 this, SLOT(onClearSelection()) );
1096 } 1096 }
1097 if ( e->type() == QEvent::Leave ) { 1097 if ( e->type() == QEvent::Leave ) {
1098 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1098 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1099 this, SLOT(onClearSelection()) ); 1099 this, SLOT(onClearSelection()) );
1100 } 1100 }
1101 return QFrame::eventFilter( obj, e ); 1101 return QFrame::eventFilter( obj, e );
1102} 1102}
1103 1103
1104/* ------------------------------------------------------------------------- */ 1104/* ------------------------------------------------------------------------- */
1105/* */ 1105/* */
1106/* Frame */ 1106/* Frame */
1107/* */ 1107/* */
1108/* ------------------------------------------------------------------------- */ 1108/* ------------------------------------------------------------------------- */
1109 1109
1110void TEWidget::frameChanged() 1110void TEWidget::frameChanged()
1111{ 1111{
1112 propagateSize(); 1112 propagateSize();
1113 update(); 1113 update();
1114} 1114}
1115 1115
1116/* ------------------------------------------------------------------------- */ 1116/* ------------------------------------------------------------------------- */
1117/* */ 1117/* */
1118/* Sound */ 1118/* Sound */
1119/* */ 1119/* */
1120/* ------------------------------------------------------------------------- */ 1120/* ------------------------------------------------------------------------- */
1121 1121
1122void TEWidget::Bell() 1122void TEWidget::Bell()
1123{ 1123{
1124 QApplication::beep(); 1124 QApplication::beep();
1125} 1125}
1126 1126
1127/* ------------------------------------------------------------------------- */ 1127/* ------------------------------------------------------------------------- */
1128/* */ 1128/* */
1129/* Auxiluary */ 1129/* Auxiluary */
1130/* */ 1130/* */
1131/* ------------------------------------------------------------------------- */ 1131/* ------------------------------------------------------------------------- */
1132 1132
1133void TEWidget::clearImage() 1133void TEWidget::clearImage()
1134// initialize the image 1134// initialize the image
1135// for internal use only 1135// for internal use only
1136{ 1136{
1137 for (int y = 0; y < lines; y++) 1137 for (int y = 0; y < lines; y++)
1138 for (int x = 0; x < columns; x++) 1138 for (int x = 0; x < columns; x++)
1139 { 1139 {
1140 image[loc(x,y)].c = 0xff; //' '; 1140 image[loc(x,y)].c = 0xff; //' ';
1141 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1141 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1142 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1142 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1143 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1143 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1144 } 1144 }
1145} 1145}
1146 1146
1147// Create Image /////////////////////////////////////////////////////// 1147// Create Image ///////////////////////////////////////////////////////
1148 1148
1149void TEWidget::calcGeometry() 1149void TEWidget::calcGeometry()
1150{ 1150{
1151 //FIXME: set rimX == rimY == 0 when running in full screen mode. 1151 //FIXME: set rimX == rimY == 0 when running in full screen mode.
1152 1152
1153 int showhscrollbar = 1; 1153 int showhscrollbar = 1;
1154 int hwidth = 0; 1154 int hwidth = 0;
1155 int dcolumns; 1155 int dcolumns;
1156 1156
1157 if(vcolumns == 0) showhscrollbar = 0; 1157 if(vcolumns == 0) showhscrollbar = 0;
1158 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1158 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1159 1159
1160 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1160 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1161 contentsRect().height() - hwidth); 1161 contentsRect().height() - hwidth);
1162 1162
1163 if(!showhscrollbar) cornerButton()->move(0, 0); 1163 if(!showhscrollbar) cornerButton()->move(0, 0);
1164 else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); 1164 else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth);
1165 1165
1166 1166
1167 switch(scrollLoc) 1167 switch(scrollLoc)
1168 { 1168 {
1169 case SCRNONE : 1169 case SCRNONE :
1170 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1170 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1171 dcolumns = columns; 1171 dcolumns = columns;
1172 if(vcolumns) columns = vcolumns; 1172 if(vcolumns) columns = vcolumns;
1173 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1173 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1174 if(showhscrollbar) 1174 if(showhscrollbar)
1175 blX = -hposition * font_w; 1175 blX = -hposition * font_w;
1176 brX = blX; 1176 brX = blX;
1177 scrollbar->hide(); 1177 scrollbar->hide();
1178 break; 1178 break;
1179 case SCRLEFT : 1179 case SCRLEFT :
1180 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1180 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1181 dcolumns = columns; 1181 dcolumns = columns;
1182 if(vcolumns) columns = vcolumns; 1182 if(vcolumns) columns = vcolumns;
1183 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1183 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1184 if(showhscrollbar) 1184 if(showhscrollbar)
1185 brX = -hposition * font_w; 1185 brX = -hposition * font_w;
1186 blX = brX + scrollbar->width(); 1186 blX = brX + scrollbar->width();
1187 scrollbar->move(contentsRect().topLeft()); 1187 scrollbar->move(contentsRect().topLeft());
1188 scrollbar->show(); 1188 scrollbar->show();
1189 break; 1189 break;
1190 case SCRRIGHT: 1190 case SCRRIGHT:
1191 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1191 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1192 dcolumns = columns; 1192 dcolumns = columns;
1193 if(vcolumns) columns = vcolumns; 1193 if(vcolumns) columns = vcolumns;
1194 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1194 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1195 if(showhscrollbar) 1195 if(showhscrollbar)
1196 blX = -hposition * font_w; 1196 blX = -hposition * font_w;
1197 brX = blX; 1197 brX = blX;
1198 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1198 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1199 scrollbar->show(); 1199 scrollbar->show();
1200 break; 1200 break;
1201 } 1201 }
1202 //FIXME: support 'rounding' styles 1202 //FIXME: support 'rounding' styles
1203 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1203 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1204 bY = (contentsRect().height() - (lines *font_h)) / 2; 1204 bY = (contentsRect().height() - (lines *font_h)) / 2;
1205 1205
1206 if(showhscrollbar == 1) 1206 if(showhscrollbar == 1)
1207 { 1207 {
1208 hscrollbar->resize(contentsRect().width() - hwidth, hwidth); 1208 hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
1209 hscrollbar->setRange(0, vcolumns - dcolumns); 1209 hscrollbar->setRange(0, vcolumns - dcolumns);
1210 1210
1211 QPoint p = contentsRect().bottomLeft(); 1211 QPoint p = contentsRect().bottomLeft();
1212 hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1212 hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
1213 hscrollbar->show(); 1213 hscrollbar->show();
1214 } 1214 }
1215 else hscrollbar->hide(); 1215 else hscrollbar->hide();
1216 1216
1217 if(showhscrollbar == 1) 1217 if(showhscrollbar == 1)
1218 { 1218 {
1219 lines = lines - (hwidth / font_h) - 1; 1219 lines = lines - (hwidth / font_h) - 1;
1220 if(lines < 1) lines = 1; 1220 if(lines < 1) lines = 1;
1221 } 1221 }
1222} 1222}
1223 1223
1224void TEWidget::makeImage() 1224void TEWidget::makeImage()
1225//FIXME: rename 'calcGeometry? 1225//FIXME: rename 'calcGeometry?
1226{ 1226{
1227 calcGeometry(); 1227 calcGeometry();
1228 image = (ca*) malloc(lines*columns*sizeof(ca)); 1228 image = (ca*) malloc(lines*columns*sizeof(ca));
1229 clearImage(); 1229 clearImage();
1230} 1230}
1231 1231
1232// calculate the needed size 1232// calculate the needed size
1233QSize TEWidget::calcSize(int cols, int lins) const 1233QSize TEWidget::calcSize(int cols, int lins) const
1234{ 1234{
1235 int frw = width() - contentsRect().width(); 1235 int frw = width() - contentsRect().width();
1236 int frh = height() - contentsRect().height(); 1236 int frh = height() - contentsRect().height();
1237 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1237 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1238 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1238 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1239} 1239}
1240 1240
1241QSize TEWidget::sizeHint() const 1241QSize TEWidget::sizeHint() const
1242{ 1242{
1243 return size(); 1243 return size();
1244} 1244}
1245 1245
1246void TEWidget::styleChange(QStyle &) 1246void TEWidget::styleChange(QStyle &)
1247{ 1247{
1248 propagateSize(); 1248 propagateSize();
1249} 1249}
1250 1250
1251#ifndef QT_NO_DRAGANDDROP 1251#ifdef QT_NO_DRAGANDDROP_FOO
1252 1252
1253/* --------------------------------------------------------------------- */ 1253/* --------------------------------------------------------------------- */
1254/* */ 1254/* */
1255/* Drag & Drop */ 1255/* Drag & Drop */
1256/* */ 1256/* */
1257/* --------------------------------------------------------------------- */ 1257/* --------------------------------------------------------------------- */
1258 1258
1259 1259
1260void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1260void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1261{ 1261{
1262 e->accept(QTextDrag::canDecode(e) || 1262 e->accept(QTextDrag::canDecode(e) ||
1263 QUriDrag::canDecode(e)); 1263 QUriDrag::canDecode(e));
1264} 1264}
1265 1265
1266void TEWidget::dropEvent(QDropEvent* event) 1266void TEWidget::dropEvent(QDropEvent* event)
1267{ 1267{
1268 // The current behaviour when url(s) are dropped is 1268 // The current behaviour when url(s) are dropped is
1269 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1269 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1270 // * in all other cases, just paste 1270 // * in all other cases, just paste
1271 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1271 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1272 QStrList strlist; 1272 QStrList strlist;
1273 int file_count = 0; 1273 int file_count = 0;
1274 dropText = ""; 1274 dropText = "";
1275 bool bPopup = true; 1275 bool bPopup = true;
1276 1276
1277 if(QUriDrag::decode(event, strlist)) { 1277 if(QUriDrag::decode(event, strlist)) {
1278 if (strlist.count()) { 1278 if (strlist.count()) {
1279 for(const char* p = strlist.first(); p; p = strlist.next()) { 1279 for(const char* p = strlist.first(); p; p = strlist.next()) {
1280 if(file_count++ > 0) { 1280 if(file_count++ > 0) {
1281 dropText += " "; 1281 dropText += " ";
1282 bPopup = false; // more than one file, don't popup 1282 bPopup = false; // more than one file, don't popup
1283 } 1283 }
1284 1284
1285/* 1285/*
1286 KURL url(p); 1286 KURL url(p);
1287 if (url.isLocalFile()) { 1287 if (url.isLocalFile()) {
1288 dropText += url.path(); // local URL : remove protocol 1288 dropText += url.path(); // local URL : remove protocol
1289 } 1289 }
1290 else { 1290 else {
1291 dropText += url.prettyURL(); 1291 dropText += url.prettyURL();
1292 bPopup = false; // a non-local file, don't popup 1292 bPopup = false; // a non-local file, don't popup
1293 } 1293 }
1294*/ 1294*/
1295 1295
1296 } 1296 }
1297 1297
1298 if (bPopup) 1298 if (bPopup)
1299 // m_drop->popup(pos() + event->pos()); 1299 // m_drop->popup(pos() + event->pos());
1300 m_drop->popup(mapToGlobal(event->pos())); 1300 m_drop->popup(mapToGlobal(event->pos()));
1301 else 1301 else
1302 { 1302 {
1303 if (currentSession) { 1303 if (currentSession) {
1304 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1304 currentSession->getEmulation()->sendString(dropText.local8Bit());
1305 } 1305 }
1306// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1306// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1307 } 1307 }
1308 } 1308 }
1309 } 1309 }
1310 else if(QTextDrag::decode(event, dropText)) { 1310 else if(QTextDrag::decode(event, dropText)) {
1311// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1311// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1312 if (currentSession) { 1312 if (currentSession) {
1313 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1313 currentSession->getEmulation()->sendString(dropText.local8Bit());
1314 } 1314 }
1315 // Paste it 1315 // Paste it
1316 } 1316 }
1317} 1317}
1318#endif 1318#endif
1319 1319
1320 1320
1321void TEWidget::drop_menu_activated(int) 1321void TEWidget::drop_menu_activated(int)
1322{ 1322{
1323#ifndef QT_NO_DRAGANDDROP 1323#ifdef QT_NO_DRAGANDDROP_FOO
1324 switch (item) 1324 switch (item)
1325 { 1325 {
1326 case 0: // paste 1326 case 0: // paste
1327 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1327 currentSession->getEmulation()->sendString(dropText.local8Bit());
1328// KWM::activate((Window)this->winId()); 1328// KWM::activate((Window)this->winId());
1329 break; 1329 break;
1330 case 1: // cd ... 1330 case 1: // cd ...
1331 currentSession->getEmulation()->sendString("cd "); 1331 currentSession->getEmulation()->sendString("cd ");
1332 struct stat statbuf; 1332 struct stat statbuf;
1333 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1333 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1334 { 1334 {
1335 if ( !S_ISDIR(statbuf.st_mode) ) 1335 if ( !S_ISDIR(statbuf.st_mode) )
1336 { 1336 {
1337/* 1337/*
1338 KURL url; 1338 KURL url;
1339 url.setPath( dropText ); 1339 url.setPath( dropText );
1340 dropText = url.directory( true, false ); // remove filename 1340 dropText = url.directory( true, false ); // remove filename
1341*/ 1341*/
1342 } 1342 }
1343 } 1343 }
1344 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1344 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1345 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1345 currentSession->getEmulation()->sendString(dropText.local8Bit());
1346 currentSession->getEmulation()->sendString("\n"); 1346 currentSession->getEmulation()->sendString("\n");
1347// KWM::activate((Window)this->winId()); 1347// KWM::activate((Window)this->winId());
1348 break; 1348 break;
1349 } 1349 }
1350#endif 1350#endif
1351} 1351}
1352 1352
1353QPushButton* TEWidget::cornerButton() { 1353QPushButton* TEWidget::cornerButton() {
1354 return m_cornerButton; 1354 return m_cornerButton;
1355} 1355}
1356 1356
1357void TEWidget::setWrapAt(int columns) 1357void TEWidget::setWrapAt(int columns)
1358{ 1358{
1359 vcolumns = columns; 1359 vcolumns = columns;
1360 propagateSize(); 1360 propagateSize();
1361 update(); 1361 update();
1362} 1362}
1363 1363
1364 1364
diff --git a/noncore/apps/opie-console/TEWidget.h b/noncore/apps/opie-console/TEWidget.h
index 6ff731b..900a659 100644
--- a/noncore/apps/opie-console/TEWidget.h
+++ b/noncore/apps/opie-console/TEWidget.h
@@ -1,214 +1,214 @@
1/* ----------------------------------------------------------------------- */ 1/* ----------------------------------------------------------------------- */
2/* */ 2/* */
3/* [te_widget.h] Terminal Emulation Widget */ 3/* [te_widget.h] Terminal Emulation Widget */
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 for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ----------------------------------------------------------------------- */ 11/* ----------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18#ifndef TE_WIDGET_H 18#ifndef TE_WIDGET_H
19#define TE_WIDGET_H 19#define TE_WIDGET_H
20 20
21#include <qwidget.h> 21#include <qwidget.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qscrollbar.h> 26#include <qscrollbar.h>
27 27
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30 30
31#include "TECommon.h" 31#include "TECommon.h"
32 32
33extern unsigned short vt100_graphics[32]; 33extern unsigned short vt100_graphics[32];
34 34
35 35
36 36
37 37
38 38
39class TESession; 39class TESession;
40 40
41// class Konsole; 41// class Konsole;
42 42
43class TEWidget : public QFrame 43class TEWidget : public QFrame
44// a widget representing attributed text 44// a widget representing attributed text
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48// friend class Konsole; 48// friend class Konsole;
49 49
50public: 50public:
51 51
52 TEWidget(QWidget *parent=0, const char *name=0); 52 TEWidget(QWidget *parent=0, const char *name=0);
53 virtual ~TEWidget(); 53 virtual ~TEWidget();
54 54
55public: 55public:
56 56
57 QColor getDefaultBackColor(); 57 QColor getDefaultBackColor();
58 QPushButton *cornerButton(); 58 QPushButton *cornerButton();
59 59
60 const ColorEntry* getColorTable() const; 60 const ColorEntry* getColorTable() const;
61 const ColorEntry* getdefaultColorTable() const; 61 const ColorEntry* getdefaultColorTable() const;
62 void setColorTable(const ColorEntry table[]); 62 void setColorTable(const ColorEntry table[]);
63 63
64 void setScrollbarLocation(int loc); 64 void setScrollbarLocation(int loc);
65 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; 65 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
66 66
67 void setScroll(int cursor, int lines); 67 void setScroll(int cursor, int lines);
68 void doScroll(int lines); 68 void doScroll(int lines);
69 69
70 void emitSelection(); 70 void emitSelection();
71 71
72 void setWrapAt(int columns); 72 void setWrapAt(int columns);
73 73
74public: 74public:
75 75
76 void setImage(const ca* const newimg, int lines, int columns); 76 void setImage(const ca* const newimg, int lines, int columns);
77 77
78 int Lines() { return lines; } 78 int Lines() { return lines; }
79 int Columns() { return columns; } 79 int Columns() { return columns; }
80 80
81 void calcGeometry(); 81 void calcGeometry();
82 void propagateSize(); 82 void propagateSize();
83 QSize calcSize(int cols, int lins) const; 83 QSize calcSize(int cols, int lins) const;
84 84
85 QSize sizeHint() const; 85 QSize sizeHint() const;
86 86
87public: 87public:
88 88
89 void Bell(); 89 void Bell();
90 void emitText(QString text); 90 void emitText(QString text);
91 void pasteClipboard(); 91 void pasteClipboard();
92 92
93signals: 93signals:
94 94
95 void keyPressedSignal(QKeyEvent *e); 95 void keyPressedSignal(QKeyEvent *e);
96 void mouseSignal(int cb, int cx, int cy); 96 void mouseSignal(int cb, int cx, int cy);
97 void changedImageSizeSignal(int lines, int columns); 97 void changedImageSizeSignal(int lines, int columns);
98 void changedHistoryCursor(int value); 98 void changedHistoryCursor(int value);
99 void configureRequest( TEWidget*, int state, int x, int y ); 99 void configureRequest( TEWidget*, int state, int x, int y );
100 100
101 void clearSelectionSignal(); 101 void clearSelectionSignal();
102 void beginSelectionSignal( const int x, const int y ); 102 void beginSelectionSignal( const int x, const int y );
103 void extendSelectionSignal( const int x, const int y ); 103 void extendSelectionSignal( const int x, const int y );
104 void endSelectionSignal(const BOOL preserve_line_breaks); 104 void endSelectionSignal(const BOOL preserve_line_breaks);
105 105
106 106
107protected: 107protected:
108 108
109 virtual void styleChange( QStyle& ); 109 virtual void styleChange( QStyle& );
110 110
111 bool eventFilter( QObject *, QEvent * ); 111 bool eventFilter( QObject *, QEvent * );
112 112
113 void drawAttrStr(QPainter &paint, QRect rect, 113 void drawAttrStr(QPainter &paint, QRect rect,
114 QString& str, ca attr, BOOL pm, BOOL clear); 114 QString& str, ca attr, BOOL pm, BOOL clear);
115 void paintEvent( QPaintEvent * ); 115 void paintEvent( QPaintEvent * );
116 116
117 void resizeEvent(QResizeEvent*); 117 void resizeEvent(QResizeEvent*);
118 118
119 void fontChange(const QFont &font); 119 void fontChange(const QFont &font);
120 void frameChanged(); 120 void frameChanged();
121 121
122 void mouseDoubleClickEvent(QMouseEvent* ev); 122 void mouseDoubleClickEvent(QMouseEvent* ev);
123 void mousePressEvent( QMouseEvent* ); 123 void mousePressEvent( QMouseEvent* );
124 void mouseReleaseEvent( QMouseEvent* ); 124 void mouseReleaseEvent( QMouseEvent* );
125 void mouseMoveEvent( QMouseEvent* ); 125 void mouseMoveEvent( QMouseEvent* );
126 126
127 void focusInEvent( QFocusEvent * ); 127 void focusInEvent( QFocusEvent * );
128 void focusOutEvent( QFocusEvent * ); 128 void focusOutEvent( QFocusEvent * );
129 bool focusNextPrevChild( bool next ); 129 bool focusNextPrevChild( bool next );
130 130
131#ifndef QT_NO_DRAGANDDROP 131#ifdef QT_NO_DRAGANDDROP_FOO_BAR_
132 // Dnd 132 // Dnd
133 void dragEnterEvent(QDragEnterEvent* event); 133 void dragEnterEvent(QDragEnterEvent* event);
134 void dropEvent(QDropEvent* event); 134 void dropEvent(QDropEvent* event);
135#endif 135#endif
136 136
137 virtual int charClass(char) const; 137 virtual int charClass(char) const;
138 138
139 void clearImage(); 139 void clearImage();
140 140
141public: 141public:
142 const QPixmap *backgroundPixmap(); 142 const QPixmap *backgroundPixmap();
143 143
144 void setSelection(const QString &t); 144 void setSelection(const QString &t);
145 145
146 virtual void setFont(const QFont &); 146 virtual void setFont(const QFont &);
147 void setVTFont(const QFont &); 147 void setVTFont(const QFont &);
148 QFont getVTFont(); 148 QFont getVTFont();
149 149
150 void setMouseMarks(bool on); 150 void setMouseMarks(bool on);
151 151
152public slots: 152public slots:
153 153
154 void onClearSelection(); 154 void onClearSelection();
155 155
156protected slots: 156protected slots:
157 157
158 void scrollChanged(int value); 158 void scrollChanged(int value);
159 void hscrollChanged(int value); 159 void hscrollChanged(int value);
160 void blinkEvent(); 160 void blinkEvent();
161 161
162private: 162private:
163 163
164 QChar (*fontMap)(QChar); // possible vt100 font extention 164 QChar (*fontMap)(QChar); // possible vt100 font extention
165 165
166 bool fixed_font; // has fixed pitch 166 bool fixed_font; // has fixed pitch
167 int font_h; // height 167 int font_h; // height
168 int font_w; // width 168 int font_w; // width
169 int font_a; // ascend 169 int font_a; // ascend
170 170
171 int blX; // actual offset (left) 171 int blX; // actual offset (left)
172 int brX; // actual offset (right) 172 int brX; // actual offset (right)
173 int bY; // actual offset 173 int bY; // actual offset
174 174
175 int lines; 175 int lines;
176 int columns; 176 int columns;
177 ca *image; // [lines][columns] 177 ca *image; // [lines][columns]
178 178
179 ColorEntry color_table[TABLE_COLORS]; 179 ColorEntry color_table[TABLE_COLORS];
180 180
181 BOOL resizing; 181 BOOL resizing;
182 bool mouse_marks; 182 bool mouse_marks;
183 183
184 void makeImage(); 184 void makeImage();
185 185
186 QPoint iPntSel; // initial selection point 186 QPoint iPntSel; // initial selection point
187 QPoint pntSel; // current selection point 187 QPoint pntSel; // current selection point
188 int actSel; // selection state 188 int actSel; // selection state
189 BOOL word_selection_mode; 189 BOOL word_selection_mode;
190 BOOL preserve_line_breaks; 190 BOOL preserve_line_breaks;
191 191
192 QPushButton *m_cornerButton; 192 QPushButton *m_cornerButton;
193 QClipboard* cb; 193 QClipboard* cb;
194 QScrollBar* scrollbar, *hscrollbar; 194 QScrollBar* scrollbar, *hscrollbar;
195 int scrollLoc; 195 int scrollLoc;
196 int hposition, vcolumns; 196 int hposition, vcolumns;
197 197
198//#define SCRNONE 0 198//#define SCRNONE 0
199//#define SCRLEFT 1 199//#define SCRLEFT 1
200//#define SCRRIGHT 2 200//#define SCRRIGHT 2
201 201
202 BOOL blinking; // hide text in paintEvent 202 BOOL blinking; // hide text in paintEvent
203 BOOL hasBlinker; // has characters to blink 203 BOOL hasBlinker; // has characters to blink
204 QTimer* blinkT; // active when hasBlinker 204 QTimer* blinkT; // active when hasBlinker
205 QPopupMenu* m_drop; 205 QPopupMenu* m_drop;
206 QString dropText; 206 QString dropText;
207 public: 207 public:
208 // current session in this widget 208 // current session in this widget
209 TESession *currentSession; 209 TESession *currentSession;
210private slots: 210private slots:
211 void drop_menu_activated(int item); 211 void drop_menu_activated(int item);
212}; 212};
213 213
214#endif // TE_WIDGET_H 214#endif // TE_WIDGET_H