diff --git a/ptyiface.cpp b/ptyiface.cpp index c644629..f5e4307 100644 --- a/ptyiface.cpp +++ b/ptyiface.cpp @@ -68,8 +68,8 @@ PtyIFace::PtyIFace(int pid, int masterFd, Terminal *term, QString charset, QObje iTerm->setPtyIFace(this); - resize(iTerm->termSize()); - connect(iTerm,SIGNAL(termSizeChanged(QSize)),this,SLOT(resize(QSize))); + resize(iTerm->rows(), iTerm->columns()); + connect(iTerm,SIGNAL(termSizeChanged(int,int)),this,SLOT(resize(int,int))); iReadNotifier = new QSocketNotifier(iMasterFd, QSocketNotifier::Read, this); connect(iReadNotifier,SIGNAL(activated(int)),this,SLOT(readActivated())); @@ -104,14 +104,14 @@ void PtyIFace::readActivated() iTerm->insertInBuffer( iTextCodec->toUnicode(data) ); } -void PtyIFace::resize(QSize newSize) +void PtyIFace::resize(int rows, int columns) { if(childProcessQuit) return; winsize winp; - winp.ws_col = newSize.width(); - winp.ws_row = newSize.height(); + winp.ws_col = columns; + winp.ws_row = rows; ioctl(iMasterFd, TIOCSWINSZ, &winp); } diff --git a/ptyiface.h b/ptyiface.h index 952dbf2..596dd72 100644 --- a/ptyiface.h +++ b/ptyiface.h @@ -38,10 +38,8 @@ class PtyIFace : public QObject void writeTerm(const QString &chars); bool failed() { return iFailed; } -public slots: - void resize(QSize newSize); - private slots: + void resize(int rows, int columns); void readActivated(); private: diff --git a/qml/Main.qml b/qml/Main.qml index 2ce05cb..ec968a4 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -294,9 +294,6 @@ Item { NotifyWin { id: aboutDialog - property int termW - property int termH - text: { var str = "FingerTerm " + util.versionString() + "
\n" + "" + @@ -304,11 +301,11 @@ Item { "Config files for adjusting settings are at:
\n" + util.configPath() + "/

\n" + "Source code:
\nhttps://git.merproject.org/mer-core/fingerterm/" - if (termH != 0 && termW != 0) { + if (term.rows != 0 && term.columns != 0) { str += "

Current window title: " + util.windowTitle.substring(0,40) + ""; //cut long window title if(util.windowTitle.length>40) str += "..."; - str += "
Current terminal size: " + termW + "x" + termH + ""; + str += "
Current terminal size: " + term.columns + "×" + term.rows + ""; str += "
Charset: " + util.charset + ""; } str += "
"; diff --git a/qml/MenuFingerterm.qml b/qml/MenuFingerterm.qml index 02c4bd3..acee889 100644 --- a/qml/MenuFingerterm.qml +++ b/qml/MenuFingerterm.qml @@ -176,7 +176,7 @@ Item { text: "+" onClicked: { util.fontSize = util.fontSize + window.pixelRatio - util.notifyText(term.termSize().width+"x"+term.termSize().height); + util.notifyText(term.columns + "×" + term.rows); } width: window.buttonWidthHalf height: window.buttonHeightSmall @@ -185,7 +185,7 @@ Item { text: "-" onClicked: { util.fontSize = util.fontSize - window.pixelRatio - util.notifyText(term.termSize().width+"x"+term.termSize().height); + util.notifyText(term.columns + "×" + term.rows); } width: window.buttonWidthHalf height: window.buttonHeightSmall @@ -361,8 +361,6 @@ Item { text: "About" onClicked: { menuWin.showing = false; - aboutDialog.termW = term.termSize().width - aboutDialog.termH = term.termSize().height aboutDialog.show = true } } diff --git a/terminal.cpp b/terminal.cpp index 0a200fa..b23c2b3 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -128,7 +128,7 @@ void Terminal::setTermSize(QSize size) resetTabs(); - emit termSizeChanged(size); + emit termSizeChanged(size.height(), size.width()); } } @@ -349,7 +349,7 @@ void Terminal::insertInBuffer(const QString& chars) if(iNewLineMode) setCursorPos(QPoint(1,cursorPos().y())); } - else if(cursorPos().x() <= termSize().width()) // ignore newline after cols (terminfo: xenl) + else if(cursorPos().x() <= columns()) // ignore newline after cols (terminfo: xenl) { if(iNewLineMode) setCursorPos(QPoint(1,cursorPos().y()+1)); @@ -1046,9 +1046,9 @@ void Terminal::escControlChar(const QString& seq) return; if( seq.at(0) == '#' && seq.at(1)=='8' ) { // test mode, fill screen with 'E' clearAll(true); - for(int i=0; i line; - for(int j=0; j >& buffer(); @@ -98,11 +101,14 @@ class Terminal : public QObject Q_INVOKABLE void clearSelection(); bool hasSelection(); + int rows(); + int columns(); + TermChar zeroChar; signals: void cursorPosChanged(QPoint newPos); - void termSizeChanged(QSize newSize); + void termSizeChanged(int rows, int columns); void displayBufferChanged(); void selectionChanged(); void scrollBackBufferAdjusted(bool reset); diff --git a/textrender.cpp b/textrender.cpp index 8547a38..85fe5e3 100644 --- a/textrender.cpp +++ b/textrender.cpp @@ -106,17 +106,17 @@ void TextRender::paint(QPainter* painter) if(from<0) from=0; int to = sTerm->backBuffer().size(); - if(to-from > sTerm->termSize().height()) - to = from + sTerm->termSize().height(); + if(to-from > sTerm->rows()) + to = from + sTerm->rows(); paintFromBuffer(painter, sTerm->backBuffer(), from, to, y); - if(to-from < sTerm->termSize().height() && sTerm->buffer().size()>0) { - int to2 = sTerm->termSize().height() - (to-from); + if(to-from < sTerm->rows() && sTerm->buffer().size()>0) { + int to2 = sTerm->rows() - (to-from); if(to2 > sTerm->buffer().size()) to2 = sTerm->buffer().size(); paintFromBuffer(painter, sTerm->buffer(), 0, to2, y); } } else { - int count = qMin(sTerm->termSize().height(), sTerm->buffer().size()); + int count = qMin(sTerm->rows(), sTerm->buffer().size()); paintFromBuffer(painter, sTerm->buffer(), 0, count, y); } @@ -145,12 +145,12 @@ void TextRender::paint(QPainter* painter) end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight()); } else { start = charsToPixels(selection.topLeft()); - end = charsToPixels(QPoint(sTerm->termSize().width(), selection.top())); + end = charsToPixels(QPoint(sTerm->columns(), selection.top())); painter->drawRect(start.x(), start.y(), end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight()); start = charsToPixels(QPoint(1, selection.top()+1)); - end = charsToPixels(QPoint(sTerm->termSize().width(), selection.bottom()-1)); + end = charsToPixels(QPoint(sTerm->columns(), selection.bottom()-1)); painter->drawRect(start.x(), start.y(), end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight()); @@ -181,7 +181,7 @@ void TextRender::paintFromBuffer(QPainter* painter, QList >& buf else painter->setOpacity(1.0); - int xcount = qMin(buffer.at(i).count(), sTerm->termSize().width()); + int xcount = qMin(buffer.at(i).count(), sTerm->columns()); // background for the current line currentX = leftmargin;