author | llornkcor <llornkcor> | 2004-01-17 22:19:17 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-01-17 22:19:17 (UTC) |
commit | e9700698b2d664a688af20008095551624c995ae (patch) (side-by-side diff) | |
tree | 0beaf08275a67e674c7cdd06df5c8431f538d59a | |
parent | 839775ea257f2c9be752a77c41a09416469df591 (diff) | |
download | opie-e9700698b2d664a688af20008095551624c995ae.zip opie-e9700698b2d664a688af20008095551624c995ae.tar.gz opie-e9700698b2d664a688af20008095551624c995ae.tar.bz2 |
fix for ascii char width
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index d0850e3..ec1b30c 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -241,14 +241,24 @@ static QChar identicalMap(QChar c) } void TEWidget::fontChange(const QFont &) { QFontMetrics fm(font()); font_h = fm.height(); - font_w = fm.maxWidth(); - font_a = fm.ascent(); + + // 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()); fontMap = @@ -1017,12 +1027,13 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) #ifdef FAKE_CTRL_AND_ALT static bool control = FALSE; static bool alt = FALSE; // 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; bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); switch (ke->key()) { case Key_F9: // let this be "Control" control = keydown; @@ -1055,13 +1066,17 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) if ( e->type() == QEvent::KeyPress ) { QKeyEvent* ke = (QKeyEvent*)e; actSel=0; // Key stroke implies a screen update, so TEWidget won't // know where the current selection is. // 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 } |