summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEHistory.cpp19
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp107
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp157
-rw-r--r--core/apps/embeddedkonsole/TEWidget.h15
-rw-r--r--core/apps/embeddedkonsole/TEmulation.cpp27
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp34
6 files changed, 318 insertions, 41 deletions
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp
index 317ce57..db9d10c 100644
--- a/core/apps/embeddedkonsole/TEHistory.cpp
+++ b/core/apps/embeddedkonsole/TEHistory.cpp
@@ -108,36 +108,42 @@ void HistoryBuffer::setScroll(bool on)
length = 0;
}
}
bool HistoryBuffer::hasScroll()
{
return ion >= 0;
}
void HistoryBuffer::add(const unsigned char* bytes, int len)
{ int rc;
assert(hasScroll());
- rc = lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; }
- rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; }
+ rc = lseek( ion, length, SEEK_SET);
+ if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; }
+ rc = write( ion, bytes, len);
+ if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; }
length += rc;
}
-void HistoryBuffer::get(unsigned char* bytes, int len, int loc)
-{ int rc;
+void HistoryBuffer::get(unsigned char* bytes, int len, int loc) {
+ int rc;
assert(hasScroll());
+// qDebug("history get len %d, loc %d, length %d", len, loc, length);
if (loc < 0 || len < 0 || loc + len > length)
fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc);
- rc = lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; }
- rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; }
+
+ rc = lseek( ion, loc, SEEK_SET);
+ if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; }
+ rc = read( ion, bytes, len);
+ if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; }
}
int HistoryBuffer::len()
{
return length;
}
// History Scroll //////////////////////////////////////
/*
The history scroll makes a Row(Row(Cell)) from
two history buffers. The index buffer contains
@@ -186,24 +192,25 @@ int HistoryScroll::startOfLine(int lineno)
if (!hasScroll()) return 0;
if (lineno <= getLines())
{ int res;
index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int));
return res;
}
return cells.len();
}
void HistoryScroll::getCells(int lineno, int colno, int count, ca res[])
{
assert(hasScroll());
+//get(unsigned char* bytes, int len, int loc)
cells.get((unsigned char*)res,count*sizeof(ca),startOfLine(lineno)+colno*sizeof(ca));
}
void HistoryScroll::addCells(ca text[], int count)
{
if (!hasScroll()) return;
cells.add((unsigned char*)text,count*sizeof(ca));
}
void HistoryScroll::addLine()
{
if (!hasScroll()) return;
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index a3d115d..50807d3 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -6,24 +6,25 @@
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
+// enhancements added by L.J. Potter <ljp@llornkcor.com>
/*! \file
*/
/*! \class TEScreen
\brief The image manipulated by the emulation.
This class implements the operations of the terminal emulation framework.
It is a complete passive device, driven by the emulation decoder
(TEmuVT102). By this it forms in fact an ADT, that defines operations
on a rectangular image.
@@ -41,46 +42,49 @@
\sa TEWidget \sa VT102Emulation
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// #include <kdebug.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
+#include <qpe/config.h>
#include "TEScreen.h"
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
//FIXME: see if we can get this from terminfo.
#define BS_CLEARS FALSE
#define loc(X,Y) ((Y)*columns+(X))
/*! creates a `TEScreen' of `lines' lines and `columns' columns.
*/
TEScreen::TEScreen(int lines, int columns)
{
this->lines = lines;
this->columns = columns;
+// qDebug("Columns %d", columns);
image = (ca*) malloc(lines*columns*sizeof(ca));
tabstops = NULL; initTabStops();
histCursor = 0;
+ horzCursor = 0;
clearSelection();
reset();
}
/*! Destructor
*/
TEScreen::~TEScreen()
{
free(image);
if (tabstops) free(tabstops);
@@ -374,54 +378,50 @@ void TEScreen::restoreCursor()
/*! Assing a new size to the screen.
The topmost left position is maintained, while lower lines
or right hand side columns might be removed or filled with
spaces to fit the new size.
The region setting is reset to the whole screen and the
tab positions reinitialized.
*/
void TEScreen::resizeImage(int new_lines, int new_columns)
{
-
- if (cuY > new_lines-1)
- { // attempt to preserve focus and lines
+ if (cuY > new_lines-1) {
+// attempt to preserve focus and lines
bmargin = lines-1; //FIXME: margin lost
- for (int i = 0; i < cuY-(new_lines-1); i++)
- {
- addHistLine(); scrollUp(0,1);
+ for (int i = 0; i < cuY-(new_lines-1); i++) {
+ addHistLine(); scrollUp(horzCursor,1);
}
}
// make new image
ca* newimg = (ca*)malloc(new_lines*new_columns*sizeof(ca));
clearSelection();
// clear new image
for (int y = 0; y < new_lines; y++)
- for (int x = 0; x < new_columns; x++)
- {
+ for (int x = 0; x < new_columns; x++) {
newimg[y*new_columns+x].c = ' ';
newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
newimg[y*new_columns+x].r = DEFAULT_RENDITION;
}
int cpy_lines = QMIN(new_lines, lines);
int cpy_columns = QMIN(new_columns,columns);
// copy to new image
for (int y = 0; y < cpy_lines; y++)
- for (int x = 0; x < cpy_columns; x++)
- {
+ for (int x = 0; x < cpy_columns; x++) {
newimg[y*new_columns+x].c = image[loc(x,y)].c;
newimg[y*new_columns+x].f = image[loc(x,y)].f;
newimg[y*new_columns+x].b = image[loc(x,y)].b;
newimg[y*new_columns+x].r = image[loc(x,y)].r;
}
free(image);
image = newimg;
lines = new_lines;
columns = new_columns;
cuX = QMIN(cuX,columns-1);
cuY = QMIN(cuY,lines-1);
@@ -496,25 +496,26 @@ void TEScreen::effectiveRendition()
/*!
returns the image.
Get the size of the image by \sa getLines and \sa getColumns.
NOTE that the image returned by this function must later be
freed.
*/
ca* TEScreen::getCookedImage()
-{ int x,y;
+{
+ int x,y;
ca* merged = (ca*)malloc(lines*columns*sizeof(ca));
ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
{
int len = QMIN(columns,hist.getLineLen(y+histCursor));
int yp = y*columns;
int yq = (y+histCursor)*columns;
hist.getCells(y+histCursor,0,len,merged+yp);
for (x = len; x < columns; x++) merged[yp+x] = dft;
for (x = 0; x < columns; x++)
@@ -539,33 +540,97 @@ ca* TEScreen::getCookedImage()
}
}
// evtl. inverse display
if (getMode(MODE_Screen))
{ int i,n = lines*columns;
for (i = 0; i < n; i++)
reverseRendition(&merged[i]); // for reverse display
}
if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible
reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]);
return merged;
+
+ /*
+ int x, y, z;
+
+ ca* merged = (ca*)malloc( lines * columns * sizeof( ca));
+
+ ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
+
+// qDebug("hist lines %d, historyCursor %d, minus %d ,lines %d, columns %d",
+// hist.getLines(), histCursor, hist.getLines() - histCursor , lines, columns);
+ for (y = 0; (y < lines) && (y < ( hist.getLines() - histCursor )); y++) {
+
+ int len = QMIN( columns, hist.getLineLen( y + histCursor) );
+ int yp = y * columns;
+ int yq = ( y + histCursor) * columns;
+// qDebug("horzCursor %d, columns %d, len %d", horzCursor, columns, len);
+// qDebug("lineno %d, colno %d, count %d\n", y + histCursor, (horzCursor / 2), len );
+ qDebug("Y %d", y);
+ hist.getCells( y + histCursor, (horzCursor / 2), len, merged + yp);
+
+ for (x = len; x < columns; x++)
+ merged[yp + x] = dft;
+ for (x = 0; x < columns; x++) {
+ int p = x + yp; int q = x + yq;
+ if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
+ reverseRendition(&merged[p]); // for selection
+ }
+ }
+
+ if (lines >= hist.getLines() - histCursor) {
+ for (y = ( hist.getLines() - histCursor); y < lines ; y++) {
+ int z = horzCursor;
+ int yp = y * columns;
+ int yq = ( y + histCursor) * columns;
+ int yr = ( y - hist.getLines() + histCursor) * columns;
+// qDebug("y %d, yp %d, yq %d, columns %d, z cursor %d", y, yp, yq, columns, z);
+ for (x = 0; x < columns; x++) {
+ int p = x + yp; int q = x + yq; int r = (x + (horzCursor/2) ) + yr;
+ merged[p] = image[r];
+ if ( q >= sel_TL && q <= sel_BR )
+ reverseRendition( &merged[p]); // for selection
+ }
+ }
+ }
+
+
+// evtl. inverse display
+ if (getMode(MODE_Screen))
+ { int i, n = lines * columns;
+ for (i = 0; i < n; i++)
+ reverseRendition( &merged[i]); // for reverse display
+ }
+ if (getMode(MODE_Cursor) && ( cuY + ( hist.getLines() - histCursor) < lines)) // cursor visible
+
+ reverseRendition( &merged[ loc( cuX, cuY + ( hist.getLines() - histCursor))] );
+
+ return merged;
+ */
+
}
/*!
*/
void TEScreen::reset()
{
+ Config cfg("Konsole");
+ cfg.setGroup("ScrollBar");
+ if( !cfg.readBoolEntry("HorzScroll",0) )
setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin
+
+
resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1]
resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke
setMode(MODE_Cursor); // cursor visible
resetMode(MODE_Screen); // screen not inverse
resetMode(MODE_NewLine);
tmargin=0;
bmargin=lines-1;
setDefaultRendition();
saveCursor();
@@ -650,24 +715,25 @@ void TEScreen::checkSelection(int from, int to)
}
void TEScreen::ShowCharacter(unsigned short c)
{
// Note that VT100 does wrapping BEFORE putting the character.
// This has impact on the assumption of valid cursor positions.
// We indicate the fact that a newline has to be triggered by
// putting the cursor one right to the last column of the screen.
if (cuX >= columns)
{
if (getMode(MODE_Wrap)) NextLine(); else cuX = columns-1;
+ // comment out for no wrap
}
if (getMode(MODE_Insert)) insertChars(1);
int i = loc(cuX,cuY);
checkSelection(i, i); // check if selection is still valid.
image[i].c = c;
image[i].f = ef_fg;
image[i].b = ef_bg;
image[i].r = ef_re;
@@ -678,43 +744,48 @@ void TEScreen::ShowCharacter(unsigned short c)
// Region commands -------------------------------------------------------------
/*! scroll up `n' lines within current region.
The `n' new lines are cleared.
\sa setRegion \sa scrollDown
*/
void TEScreen::scrollUp(int from, int n)
{
if (n <= 0 || from + n > bmargin) return;
//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
+
moveImage(loc(0,from),loc(0,from+n),loc(columns-1,bmargin));
clearImage(loc(0,bmargin-n+1),loc(columns-1,bmargin),' ');
}
/*! scroll down `n' lines within current region.
The `n' new lines are cleared.
\sa setRegion \sa scrollUp
*/
void TEScreen::scrollDown(int from, int n)
{
+
//FIXME: make sure `tmargin', `bmargin', `from', `n' is in bounds.
if (n <= 0) return;
if (from > bmargin) return;
if (from + n > bmargin) n = bmargin - from;
+
moveImage(loc(0,from+n),loc(0,from),loc(columns-1,bmargin-n));
clearImage(loc(0,from),loc(columns-1,from+n-1),' ');
}
+
+
/*! position the cursor to a specific line and column. */
void TEScreen::setCursorYX(int y, int x)
{
setCursorY(y); setCursorX(x);
}
/*! Set the cursor to x-th line. */
void TEScreen::setCursorX(int x)
{
if (x == 0) x = 1; // Default
x -= 1; // Adjust
@@ -1143,51 +1214,61 @@ FIXME:
The space prevents concatenation of the last word of one
line with the first of the next.
*/
void TEScreen::addHistLine()
{
assert(hasScroll() || histCursor == 0);
// add to hist buffer
// we have to take care about scrolling, too...
- if (hasScroll())
- { ca dft;
+ if (hasScroll()){
+ ca dft;
int end = columns-1;
while (end >= 0 && image[end] == dft)
end -= 1;
hist.addCells(image,end+1);
hist.addLine();
// adjust history cursor
histCursor += (hist.getLines()-1 == histCursor);
}
if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround
}
void TEScreen::setHistCursor(int cursor)
{
histCursor = cursor; //FIXME:rangecheck
}
+void TEScreen::setHorzCursor(int cursor)
+{
+ horzCursor = cursor;
+}
+
int TEScreen::getHistCursor()
{
return histCursor;
}
+int TEScreen::getHorzCursor()
+{
+ return horzCursor;
+}
+
int TEScreen::getHistLines()
{
return hist.getLines();
}
void TEScreen::setScroll(bool on)
{
histCursor = 0;
clearSelection();
hist.setScroll(on);
}
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index b1ad008..c10c7a8 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -43,24 +43,31 @@
*/
/* TODO
- evtl. be sensitive to `paletteChange' while using default colors.
- set different 'rounding' styles? I.e. have a mode to show clipped chars?
*/
// #include "config.h"
#include "TEWidget.h"
#include "session.h"
#include <qpe/config.h>
+#include <qpe/resource.h>
+#include <qpe/sound.h>
+
+#ifdef QWS
+#include <qpe/qcopenvelope_qws.h>
+#endif
+
#include <qcursor.h>
#include <qregexp.h>
#include <qpainter.h>
#include <qclipboard.h>
#include <qstyle.h>
#include <qfile.h>
#include <qdragobject.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
@@ -278,52 +285,62 @@ void TEWidget::setFont(const QFont &)
TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
{
#ifndef QT_NO_CLIPBOARD
cb = QApplication::clipboard();
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
#endif
scrollbar = new QScrollBar(this);
scrollbar->setCursor( arrowCursor );
connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
+ hScrollbar = new QScrollBar(this);
+ hScrollbar->setCursor( arrowCursor );
+ hScrollbar->setOrientation(QScrollBar::Horizontal);
+ hScrollbar->setMaximumHeight(16);
+
+ connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
+
Config cfg("Konsole");
cfg.setGroup("ScrollBar");
switch( cfg.readNumEntry("Position",2)){
case 0:
scrollLoc = SCRNONE;
break;
case 1:
scrollLoc = SCRLEFT;
break;
case 2:
scrollLoc = SCRRIGHT;
break;
};
+ useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
+
blinkT = new QTimer(this);
connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
// blinking = FALSE;
blinking = TRUE;
resizing = FALSE;
actSel = 0;
image = 0;
lines = 1;
columns = 1;
font_w = 1;
font_h = 1;
font_a = 1;
word_selection_mode = FALSE;
+ hposition = 0;
setMouseMarks(TRUE);
setVTFont( QFont("fixed") );
setColorTable(base_color_table); // init color table
qApp->installEventFilter( this ); //FIXME: see below
// KCursor::setAutoHideCursor( this, true );
// Init DnD ////////////////////////////////////////////////////////////////
currentSession = NULL;
// setAcceptDrops(true); // attempt
// m_drop = new QPopupMenu(this);
@@ -401,28 +418,25 @@ HCNT("setImage");
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
hasBlinker = FALSE;
int cf = -1; // undefined
int cb = -1; // undefined
int cr = -1; // undefined
int lins = QMIN(this->lines, QMAX(0,lines ));
int cols = QMIN(this->columns,QMAX(0,columns));
QChar *disstrU = new QChar[cols];
-
-//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
- for (y = 0; y < lins; y++)
- {
+ for (y = 0; y < lins; y++) {
const ca* lcl = &image[y*this->columns];
const ca* const ext = &newimg[y*columns];
if (!resizing) // not while resizing, we're expecting a paintEvent
for (x = 0; x < cols; x++)
{
hasBlinker |= (ext[x].r & RE_BLINK);
if (ext[x] != lcl[x])
{
cr = ext[x].r;
cb = ext[x].b;
if (ext[x].f != cf) cf = ext[x].f;
int lln = cols - x;
@@ -579,29 +593,36 @@ void TEWidget::propagateSize()
resizing = TRUE;
emit changedImageSizeSignal(lines, columns); // expose resizeEvent
resizing = FALSE;
}
/* ------------------------------------------------------------------------- */
/* */
/* Scrollbar */
/* */
/* ------------------------------------------------------------------------- */
-void TEWidget::scrollChanged(int)
-{
+void TEWidget::scrollChanged(int) {
emit changedHistoryCursor(scrollbar->value()); //expose
}
+void TEWidget::hScrollChanged(int loc) {
+ hposition = loc;
+ propagateSize();
+ update();
+
+// emit changedHorzCursor( hScrollbar->value()); //expose
+}
+
void TEWidget::setScroll(int cursor, int slines)
{
disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
scrollbar->setRange(0,slines);
scrollbar->setSteps(1,lines);
scrollbar->setValue(cursor);
connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
}
void TEWidget::setScrollbarLocation(int loc)
{
if (scrollLoc == loc) return; // quickly
@@ -688,24 +709,25 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev)
if (ev->state() == NoButton ) return;
if (actSel == 0) return;
// don't extend selection while pasting
if (ev->state() & MidButton) return;
//if ( !contentsRect().contains(ev->pos()) ) return;
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
int scroll = scrollbar->value();
+// int hScroll = hScrollbar->value();
// we're in the process of moving the mouse with the left button pressed
// the mouse cursor will kept catched within the bounds of the text in
// this widget.
// Adjust position within text area bounds. See FIXME above.
QPoint pos = ev->pos();
if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
// check if we produce a mouse move event by this
@@ -964,24 +986,28 @@ void TEWidget::onClearSelection()
// cursor like xterm does.
// for the auto-hide cursor feature, I added empty focusInEvent() and
// focusOutEvent() so that update() isn't called.
// For auto-hide, we need to get keypress-events, but we only get them when
// we have focus.
void TEWidget::doScroll(int lines)
{
scrollbar->setValue(scrollbar->value()+lines);
}
+void TEWidget::doHScroll(int lines) {
+ hScrollbar->setValue( hScrollbar->value()+lines);
+}
+
bool TEWidget::eventFilter( QObject *obj, QEvent *e )
{
if ( (e->type() == QEvent::Accel ||
e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
static_cast<QKeyEvent *>( e )->ignore();
return true;
}
if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
return FALSE; // not us
if ( e->type() == QEvent::Wheel) {
QApplication::sendEvent(scrollbar, e);
}
@@ -1069,25 +1095,35 @@ void TEWidget::frameChanged()
propagateSize();
update();
}
/* ------------------------------------------------------------------------- */
/* */
/* Sound */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::Bell()
{
- QApplication::beep();
+//#ifdef QT_QWS_CUSTOM
+//# ifndef QT_NO_COP
+ QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
+//# endif
+//#else
+//# ifndef QT_NO_SOUND
+// QSound::play(Resource::findSound("alarm"));
+//# endif
+//#endif
+
+// QApplication::beep();
}
/* ------------------------------------------------------------------------- */
/* */
/* Auxiluary */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::clearImage()
// initialize the image
// for internal use only
{
@@ -1096,55 +1132,150 @@ void TEWidget::clearImage()
{
image[loc(x,y)].c = 0xff; //' ';
image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
}
}
// Create Image ///////////////////////////////////////////////////////
void TEWidget::calcGeometry()
{
- //FIXME: set rimX == rimY == 0 when running in full screen mode.
+ int showhscrollbar = 1;
+ int hwidth = 0;
+ int dcolumns;
+ Config cfg("Konsole");
+ cfg.setGroup("ScrollBar");
+ useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
+
+ if(vcolumns == 0) showhscrollbar = 0;
+ if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
+
+ scrollbar->resize(QApplication::style().scrollBarExtent().width(),
+ contentsRect().height() - hwidth);
+
+ switch(scrollLoc) {
+ case SCRNONE :
+ columns = ( contentsRect().width() - 2 * rimX ) / font_w;
+ dcolumns = columns;
+ if(vcolumns) columns = vcolumns;
+ blX = (contentsRect().width() - (columns*font_w) ) / 2;
+ if(showhscrollbar)
+ blX = -hposition * font_w;
+ brX = blX;
+ scrollbar->hide();
+ break;
+ case SCRLEFT :
+ columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ dcolumns = columns;
+ if(vcolumns) columns = vcolumns;
+ brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
+ if(showhscrollbar)
+ brX = -hposition * font_w;
+ blX = brX + scrollbar->width();
+ scrollbar->move(contentsRect().topLeft());
+ scrollbar->show();
+ break;
+ case SCRRIGHT:
+ columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ dcolumns = columns;
+ if(vcolumns) columns = vcolumns;
+ blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
+ if(showhscrollbar)
+ blX = -hposition * font_w;
+ brX = blX;
+ scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
+ scrollbar->show();
+ break;
+ }
+ //FIXME: support 'rounding' styles
+ lines = ( contentsRect().height() - 2 * rimY ) / font_h;
+ bY = (contentsRect().height() - (lines *font_h)) / 2;
+
+ if(showhscrollbar == 1) {
+ hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
+ hScrollbar->setRange(0, vcolumns - dcolumns);
+
+ QPoint p = contentsRect().bottomLeft();
+ hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
+ hScrollbar->show();
+ }
+ else hScrollbar->hide();
+
+ if(showhscrollbar == 1) {
+ lines = lines - (hwidth / font_h) - 1;
+ if(lines < 1) lines = 1;
+ }
+
+ /*//FIXME: set rimX == rimY == 0 when running in full screen mode.
+ Config cfg("Konsole");
+ cfg.setGroup("ScrollBar");
+ useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
scrollbar->resize(QApplication::style().scrollBarExtent().width(),
contentsRect().height());
+ qDebug("font_w %d", font_w);
switch(scrollLoc)
{
case SCRNONE :
columns = ( contentsRect().width() - 2 * rimX ) / font_w;
blX = (contentsRect().width() - (columns*font_w) ) / 2;
brX = blX;
scrollbar->hide();
break;
case SCRLEFT :
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ if(useHorzScroll) columns = columns * (font_w/2);
brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
blX = brX + scrollbar->width();
scrollbar->move(contentsRect().topLeft());
scrollbar->show();
break;
case SCRRIGHT:
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ if(useHorzScroll) columns = columns * (font_w/2);
blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
+ if(useHorzScroll) {
+ brX = blX =2;
+ } else {
brX = blX;
+ }
scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
scrollbar->show();
break;
}
- //FIXME: support 'rounding' styles
+
+ if( !scrollbar->isHidden())
+ hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style()
+ .scrollBarExtent().height());
+ else
+ hScrollbar->resize( contentsRect().width(), QApplication::style()
+ .scrollBarExtent().height());
+
+ hScrollbar->move( 0, contentsRect().height() - SCRWIDTH);
+
+
+ if(useHorzScroll) {
+ hScrollbar->show();
+ lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h;
+ bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2;
+ } else {
+ hScrollbar->hide();
lines = ( contentsRect().height() - 2 * rimY ) / font_h;
bY = (contentsRect().height() - (lines *font_h)) / 2;
}
+ */
+ //FIXME: support 'rounding' styles
+}
void TEWidget::makeImage()
//FIXME: rename 'calcGeometry?
{
calcGeometry();
image = (ca*) malloc(lines*columns*sizeof(ca));
clearImage();
}
// calculate the needed size
QSize TEWidget::calcSize(int cols, int lins) const
{
@@ -1257,12 +1388,20 @@ void TEWidget::drop_menu_activated(int item)
*/
}
}
dropText.replace(QRegExp(" "), "\\ "); // escape spaces
currentSession->getEmulation()->sendString(dropText.local8Bit());
currentSession->getEmulation()->sendString("\n");
// KWM::activate((Window)this->winId());
break;
}
#endif
}
+void TEWidget::setWrapAt(int columns)
+{
+ vcolumns = columns;
+ propagateSize();
+ update();
+}
+
+
diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h
index 40e1aea..a480d45 100644
--- a/core/apps/embeddedkonsole/TEWidget.h
+++ b/core/apps/embeddedkonsole/TEWidget.h
@@ -51,61 +51,66 @@ public:
QColor getDefaultBackColor();
const ColorEntry* getColorTable() const;
const ColorEntry* getdefaultColorTable() const;
void setColorTable(const ColorEntry table[]);
void setScrollbarLocation(int loc);
enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
void setScroll(int cursor, int lines);
void doScroll(int lines);
+ void doHScroll(int lines);
+
+
void emitSelection();
+ void setWrapAt(int columns);
public:
void setImage(const ca* const newimg, int lines, int columns);
int Lines() { return lines; }
int Columns() { return columns; }
void calcGeometry();
void propagateSize();
QSize calcSize(int cols, int lins) const;
QSize sizeHint() const;
public:
+ bool useHorzScroll;
void Bell();
void emitText(QString text);
void pasteClipboard();
signals:
void keyPressedSignal(QKeyEvent *e);
void mouseSignal(int cb, int cx, int cy);
void changedImageSizeSignal(int lines, int columns);
void changedHistoryCursor(int value);
+ void changedHorzCursor(int value);
void configureRequest( TEWidget*, int state, int x, int y );
void clearSelectionSignal();
void beginSelectionSignal( const int x, const int y );
void extendSelectionSignal( const int x, const int y );
void endSelectionSignal(const BOOL preserve_line_breaks);
protected:
-
virtual void styleChange( QStyle& );
bool eventFilter( QObject *, QEvent * );
void drawAttrStr(QPainter &paint, QRect rect,
QString& str, ca attr, BOOL pm, BOOL clear);
void paintEvent( QPaintEvent * );
void resizeEvent(QResizeEvent*);
void fontChange(const QFont &font);
void frameChanged();
@@ -138,24 +143,25 @@ public:
void setVTFont(const QFont &);
QFont getVTFont();
void setMouseMarks(bool on);
public slots:
void onClearSelection();
protected slots:
void scrollChanged(int value);
+ void hScrollChanged(int value);
void blinkEvent();
private:
QChar (*fontMap)(QChar); // possible vt100 font extention
bool fixed_font; // has fixed pitch
int font_h; // height
int font_w; // width
int font_a; // ascend
int blX; // actual offset (left)
@@ -171,26 +177,29 @@ private:
BOOL resizing;
bool mouse_marks;
void makeImage();
QPoint iPntSel; // initial selection point
QPoint pntSel; // current selection point
int actSel; // selection state
BOOL word_selection_mode;
BOOL preserve_line_breaks;
QClipboard* cb;
- QScrollBar* scrollbar;
- int scrollLoc;
+ QScrollBar* scrollbar, *hScrollbar;
+
+ int scrollLoc, hScrollLoc;
+ int hposition, vcolumns;
+
//#define SCRNONE 0
//#define SCRLEFT 1
//#define SCRRIGHT 2
BOOL blinking; // hide text in paintEvent
BOOL hasBlinker; // has characters to blink
QTimer* blinkT; // active when hasBlinker
QPopupMenu* m_drop;
QString dropText;
public:
// current session in this widget
diff --git a/core/apps/embeddedkonsole/TEmulation.cpp b/core/apps/embeddedkonsole/TEmulation.cpp
index 6f3ad32..c19f2a1 100644
--- a/core/apps/embeddedkonsole/TEmulation.cpp
+++ b/core/apps/embeddedkonsole/TEmulation.cpp
@@ -94,36 +94,46 @@ TEmulation::TEmulation(TEWidget* gui)
{
this->gui = gui;
screen[0] = new TEScreen(gui->Lines(),gui->Columns());
screen[1] = new TEScreen(gui->Lines(),gui->Columns());
scr = screen[0];
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
connected = FALSE;
QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
+
QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
this,SLOT(onImageSizeChange(int,int)));
+
QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
this,SLOT(onHistoryCursorChange(int)));
+
+ QObject::connect(gui,SIGNAL(changedHorzCursor(int)),
+ this,SLOT(onHorzCursorChange(int)));
+
QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
this,SLOT(onKeyPress(QKeyEvent*)));
+
QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
this,SLOT(onSelectionBegin(const int,const int)) );
+
QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)),
this,SLOT(onSelectionExtend(const int,const int)) );
+
QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)),
this,SLOT(setSelection(const BOOL)) );
+
QObject::connect(gui,SIGNAL(clearSelectionSignal()),
this,SLOT(clearSelection()) );
}
/*!
*/
TEmulation::~TEmulation()
{
delete screen[0];
delete screen[1];
bulk_timer.stop();
@@ -290,26 +300,28 @@ void TEmulation::bulkNewline()
void TEmulation::showBulk()
{
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
if (connected)
{
ca* image = scr->getCookedImage(); // get the image
gui->setImage(image,
scr->getLines(),
scr->getColumns()); // actual refresh
free(image);
+
//FIXME: check that we do not trigger other draw event here.
gui->setScroll(scr->getHistCursor(),scr->getHistLines());
+
}
}
void TEmulation::bulkStart()
{
if (bulk_timer.isActive()) bulk_timer.stop();
}
void TEmulation::bulkEnd()
{
if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 )
showBulk(); // resets bulk_??cnt to 0, too.
@@ -330,34 +342,37 @@ void TEmulation::setConnect(bool c)
scr->clearSelection();
}
}
// ---------------------------------------------------------------------------
/*! triggered by image size change of the TEWidget `gui'.
This event is simply propagated to the attached screens
and to the related serial line.
*/
-void TEmulation::onImageSizeChange(int lines, int columns)
-{
+void TEmulation::onImageSizeChange(int lines, int columns) {
if (!connected) return;
screen[0]->resizeImage(lines,columns);
screen[1]->resizeImage(lines,columns);
showBulk();
emit ImageSizeChanged(lines,columns); // propagate event to serial line
}
-void TEmulation::onHistoryCursorChange(int cursor)
-{
+void TEmulation::onHistoryCursorChange(int cursor) {
if (!connected) return;
scr->setHistCursor(cursor);
showBulk();
}
-void TEmulation::setColumns(int columns)
-{
+void TEmulation::onHorzCursorChange(int cursor) {
+ if (!connected) return;
+ scr->setHorzCursor(cursor);
+ showBulk();
+}
+
+void TEmulation::setColumns(int columns) {
//FIXME: this goes strange ways.
// Can we put this straight or explain it at least?
emit changeColumns(columns);
}
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index a8ddc99..3c87ad4 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -349,39 +349,51 @@ void Konsole::init(const char* _pgm, QStrList & _args)
// for (int i = 0; commonCmds[i] != NULL; i++) {
// commonCombo->insertItem( commonCmds[i], i );
// tmp = cfg.readEntry( QString::number(i),"");
// if(tmp != "")
// commonCombo->changeItem( tmp,i );
// }
connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
scrollMenu->insertItem(tr( "None" ));
scrollMenu->insertItem(tr( "Left" ));
scrollMenu->insertItem(tr( "Right" ));
- configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
+ scrollMenu->insertSeparator(4);
+ scrollMenu->insertItem(tr( "Horizontal" ));
+ configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
+//scrollMenuSelected(-29);
+// cfg.setGroup("ScrollBar");
+// if(cfg.readBoolEntry("HorzScroll",0)) {
+// if(cfg.readNumEntry("Position",2) == 0)
+// te->setScrollbarLocation(1);
+// else
+// te->setScrollbarLocation(0);
+// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
+// te->setWrapAt(120);
+// }
// create applications /////////////////////////////////////////////////////
setCentralWidget(tab);
// load keymaps ////////////////////////////////////////////////////////////
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++)
{ KeyTrans* s = KeyTrans::find(i);
assert( s );
}
se_pgm = _pgm;
se_args = _args;
-
+ se_args.prepend("--login");
parseCommandLine();
// read and apply default values ///////////////////////////////////////////
resize(321, 321); // Dummy.
QSize currentSize = size();
if (currentSize != size())
defaultSize = size();
}
void Konsole::show()
{
if ( !nsessions ) {
newSession();
@@ -499,24 +511,26 @@ QSize Konsole::calcSize(int columns, int lines) {
QSize size;
return size;
}
}
/**
sets application window to a size based on columns X lines of the te
guest widget. Call with (0,0) for setting default size.
*/
void Konsole::setColLin(int columns, int lines)
{
+ qDebug("konsole::setColLin:: Columns %d", columns);
+
if ((columns==0) || (lines==0))
{
if (defaultSize.isEmpty()) // not in config file : set default value
{
defaultSize = calcSize(80,24);
// notifySize(24,80); // set menu items (strange arg order !)
}
resize(defaultSize);
} else {
resize(calcSize(columns, lines));
// notifySize(lines,columns); // set menu items (strange arg order !)
}
@@ -543,24 +557,25 @@ void Konsole::setFont(int fontno)
return;
}
if (se) se->setFontNo(fontno);
te->setVTFont(f);
n_font = fontno;
}
*/
// --| color selection |-------------------------------------------------------
void Konsole::changeColumns(int columns)
{
+ qDebug("change columns");
TEWidget* te = getTe();
if (te != 0) {
setColLin(columns,te->Lines());
te->update();
}
}
//FIXME: If a child dies during session swap,
// this routine might be called before
// session swap is completed.
void Konsole::doneSession(TESession*, int )
@@ -791,42 +806,53 @@ void Konsole::changeCommand(const QString &text, int c)
}
void Konsole::setColor()
{
Config cfg("Konsole");
cfg.setGroup("Colors");
int scheme = cfg.readNumEntry("Schema",1);
if(scheme != 1) colorMenuSelected( -scheme);
}
void Konsole::scrollMenuSelected(int index)
{
-// QString temp;
-// qDebug( temp.sprintf("scrollbar menu %d",index));
+ qDebug( "scrollbar menu %d",index);
TEWidget* te = getTe();
Config cfg("Konsole");
cfg.setGroup("ScrollBar");
switch( index){
case -25:
te->setScrollbarLocation(0);
cfg.writeEntry("Position",0);
break;
case -26:
te->setScrollbarLocation(1);
cfg.writeEntry("Position",1);
break;
case -27:
te->setScrollbarLocation(2);
cfg.writeEntry("Position",2);
break;
+ case -29: {
+ bool b=cfg.readBoolEntry("HorzScroll",0);
+ cfg.writeEntry("HorzScroll", !b );
+ cfg.write();
+ if(cfg.readNumEntry("Position",2) == 0)
+ te->setScrollbarLocation(1);
+ else
+ te->setScrollbarLocation(0);
+ te->setScrollbarLocation( cfg.readNumEntry("Position",2));
+ te->setWrapAt(120);
+ }
+ break;
};
}
void Konsole::editCommandListMenuSelected(int iD)
{
// QString temp;
// qDebug( temp.sprintf("edit command list %d",iD));
TEWidget* te = getTe();
Config cfg("Konsole");
cfg.setGroup("Menubar");
if( iD == -3) {