Mercurial > hg > octave-lyh
changeset 15676:aa6cba8ae88b
Inserted msleep to reduce cpu usage on grabbing data from stdin.
author | Jacob Dawid <jacob.dawid@gmail.com> |
---|---|
date | Fri, 20 Jul 2012 16:35:17 -0400 |
parents | 22bd268429d3 |
children | f620ecde2566 |
files | libqterminal/unix/SelfListener.cpp libqterminal/unix/SelfListener.h libqterminal/unix/TerminalView.cpp libqterminal/unix/TerminalView.h libqterminal/unix/Vt102Emulation.cpp |
diffstat | 5 files changed, 44 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/libqterminal/unix/SelfListener.cpp +++ b/libqterminal/unix/SelfListener.cpp @@ -1,3 +1,20 @@ +/* qterminal - a terminal widget for Qt + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "unix/SelfListener.h" SelfListener::SelfListener(int a, QObject *parent) : @@ -6,14 +23,16 @@ } void SelfListener::run() { - char buf[1025]; + char buf[4096]; int len; - - while(1) { - len = ::read(_a, buf, 1024); - if (len > 0) { - buf[len] = 0; // Just in case. - emit recvData(buf, len); - } + bool running = true; + while(running) { + while((len = ::read(_a, buf, 4096)) > 0) { + buf[len] = 0; // Just in case. + emit recvData(buf, len); + msleep(30); + } + if(len < 0) + running = false; } }
--- a/libqterminal/unix/SelfListener.h +++ b/libqterminal/unix/SelfListener.h @@ -1,3 +1,20 @@ +/* qterminal - a terminal widget for Qt + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef SELFLISTENER_H #define SELFLISTENER_H
--- a/libqterminal/unix/TerminalView.cpp +++ b/libqterminal/unix/TerminalView.cpp @@ -2422,34 +2422,6 @@ _allowBell = true; } -void TerminalView::bell(const QString&) -{ - if (_bellMode==NoBell) return; - - //limit the rate at which bells can occur - //...mainly for sound effects where rapid bells in sequence - //produce a horrible noise - if ( _allowBell ) - { - _allowBell = false; - QTimer::singleShot(500,this,SLOT(enableBell())); - - if (_bellMode==SystemBeepBell) - { - // KNotification::beep(); - } - else if (_bellMode==NotifyBell) - { - // KNotification::event("BellVisible", message,QPixmap(),this); - } - else if (_bellMode==VisualBell) - { - swapColorTable(); - QTimer::singleShot(200,this,SLOT(swapColorTable())); - } - } -} - void TerminalView::swapColorTable() { ColorEntry color = _colorTable[1];
--- a/libqterminal/unix/TerminalView.h +++ b/libqterminal/unix/TerminalView.h @@ -442,12 +442,6 @@ /** See setUsesMouse() */ bool usesMouse() const; - /** - * Shows a notification that a bell event has occurred in the terminal. - * TODO: More documentation here - */ - void bell(const QString& message); - signals: /** @@ -456,14 +450,6 @@ void keyPressedSignal(QKeyEvent *e); /** - * Emitted when the user presses the suspend or resume flow control key combinations - * - * @param suspend true if the user pressed Ctrl+S (the suspend output key combination) or - * false if the user pressed Ctrl+Q (the resume output key combination) - */ - void flowControlKeyPressed(bool suspend); - - /** * A mouse event occurred. * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release) * @param column The character column where the event occurred
--- a/libqterminal/unix/Vt102Emulation.cpp +++ b/libqterminal/unix/Vt102Emulation.cpp @@ -43,10 +43,6 @@ #include <QtGui/QKeyEvent> #include <QtCore/QByteRef> -// KDE -//#include <kdebug.h> -//#include <klocale.h> - // Konsole #include "unix/KeyboardTranslator.h" #include "unix/Screen.h" @@ -1262,5 +1258,4 @@ #endif } -//#include "moc_Vt102Emulation.cpp"