Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 148 |
1 files changed, 104 insertions, 44 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index ec1b30c..98c3cdf 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -67,4 +67,5 @@ #include <qfile.h> #include <qdragobject.h> +#include <qnamespace.h> #include <stdio.h> @@ -245,21 +246,15 @@ void TEWidget::fontChange(const QFont &) QFontMetrics fm(font()); font_h = fm.height(); - - // font_w = max width of ASCII chars (U.B.) - font_w = 0; - int fw; - for (int i = 0x20; i < 0x80; i++) { - if (isprint(i) && font_w < (fw = fm.width(i))) { - font_w = fw; - } - } - //font_w = fm.maxWidth(); - - font_a = fm.ascent(); -//printf("font_h: %d\n",font_h); -//printf("font_w: %d\n",font_w); -//printf("font_a: %d\n",font_a); -//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); -//printf("rawname: %s\n",font().rawName().ascii()); + // font_w = fm.maxWidth(); + font_w = fm.width("m"); + font_a = fm.ascent(); + printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, + fm.maxWidth(), font_w, font_a); + + //printf("font_h: %d\n",font_h); + //printf("font_w: %d\n",font_w); + //printf("font_a: %d\n",font_a); + //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); + //printf("rawname: %s\n",font().rawName().ascii()); fontMap = #if QT_VERSION < 300 @@ -308,9 +303,9 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) hScrollbar->setCursor( arrowCursor ); hScrollbar->setOrientation(QScrollBar::Horizontal); - hScrollbar->setMaximumHeight(16); + // hScrollbar->setMaximumHeight(16); connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); - Config cfg("Konsole"); + Config cfg("Qkonsole"); cfg.setGroup("ScrollBar"); switch( cfg.readNumEntry("Position",2)){ @@ -685,5 +680,6 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) int tLy = tL.y(); - word_selection_mode = FALSE; + mouse_down_x = ev->x(); + mouse_down_y = ev->y(); //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); @@ -692,4 +688,6 @@ void TEWidget::mousePressEvent(QMouseEvent* ev) QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); + word_selection_mode = (ev->state() & ShiftButton); + if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; @@ -816,4 +814,10 @@ void TEWidget::mouseReleaseEvent(QMouseEvent* ev) if ( ev->button() == LeftButton) { + if (QABS(ev->x() - mouse_down_x) < 3 + && QABS(ev->y() - mouse_down_y) < 3 + && ev->y() < qApp->desktop()->height()/8) { + emit setFullScreen(false); + } + if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); preserve_line_breaks = TRUE; @@ -1031,5 +1035,4 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); bool dele=FALSE; - if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { QKeyEvent* ke = (QKeyEvent*)e; @@ -1070,23 +1073,81 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); - if(ke->key() == Key_Escape) { - qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); - - } - - if( ke->state() == ShiftButton && ke->key() == Key_Tab) { - //lets hardcode this sucker - -// qDebug("key pressed 2 is 0x%x", ke->key()); - emitText("\\"); // expose - } - else if( ke->state() == ControlButton && ke->key() == Key_V) { - pasteClipboard(); - } -// else if( ke->state() == ControlButton && ke->key() == Key_C) { -// pasteClipboard(); -// } - else - emit keyPressedSignal(ke); // expose + + bool special_function = true; + switch(ke->key()) { + // case 0x201b: // fn-5 + // case Key_F1: + // switch sessions (?) + // emitText("\\"); // expose (??) + // break; + + case 0x2016: // fn-p + case Key_F2: + pasteClipboard(); + break; + + case 0x2018: // fn-S + case Key_F3: + emit changeSession(1); + break; + + case 0x2019: // fn-n + emit newSession(); + break; + + case Qt::Key_Tab: + if (ke->state() == ControlButton) { + emit changeSession(1); + } else { + special_function = false; + } + break; + +#if 0 + case Qt::Key_Left: + if (vcolumns == 0) { + emit changeSession(-1); + } else { + special_function = false; + } + break; + + case Qt::Key_Right: + if (vcolumns == 0) { + emit changeSession(1); + } else { + special_function = false; + } + break; +#endif + + case 0x201b: // fn-5 + case Key_F4: + emit toggleFullScreen(); + break; + + case 0x200f: // fn-1 magnify minus + case Key_F5: + emit changeFontSize(-1); + break; + + case 0x2010: // fn-2 magnify plus + case Key_F6: + emit changeFontSize(1); + break; + + default: + special_function = false; + } + if (special_function) { + return true; + } + // else if( ke->state() == ControlButton && ke->key() == Key_V) { + // pasteClipboard(); + // } + // else if( ke->state() == ControlButton && ke->key() == Key_C) { + // pasteClipboard(); + // } + emit keyPressedSignal(ke); // expose ke->accept(); #ifdef FAKE_CTRL_AND_ALT @@ -1117,5 +1178,4 @@ void TEWidget::frameChanged() update(); } - /* ------------------------------------------------------------------------- */ /* */ @@ -1168,5 +1228,5 @@ void TEWidget::calcGeometry() int hwidth = 0; int dcolumns; - Config cfg("Konsole"); + Config cfg("Qkonsole"); cfg.setGroup("ScrollBar"); useHorzScroll=cfg.readBoolEntry("HorzScroll",0); @@ -1369,5 +1429,5 @@ void TEWidget::setWrapAt(int columns) { vcolumns = columns; - propagateSize(); - update(); + propagateSize(); + update(); } |