K&R formatting

This commit is contained in:
Petr Vanek
2010-10-01 16:08:52 +02:00
parent 4ee36b8db0
commit 25661234c0
39 changed files with 8510 additions and 8226 deletions
+67 -74
View File
@@ -31,19 +31,19 @@
using namespace Konsole;
ScreenWindow::ScreenWindow(QObject* parent)
: QObject(parent)
, _windowBuffer(0)
, _windowBufferSize(0)
, _bufferNeedsUpdate(true)
, _windowLines(1)
, _currentLine(0)
, _trackOutput(true)
, _scrollCount(0)
: QObject(parent)
, _windowBuffer(0)
, _windowBufferSize(0)
, _bufferNeedsUpdate(true)
, _windowLines(1)
, _currentLine(0)
, _trackOutput(true)
, _scrollCount(0)
{
}
ScreenWindow::~ScreenWindow()
{
delete[] _windowBuffer;
delete[] _windowBuffer;
}
void ScreenWindow::setScreen(Screen* screen)
{
@@ -59,43 +59,42 @@ Screen* ScreenWindow::screen() const
Character* ScreenWindow::getImage()
{
// reallocate internal buffer if the window size has changed
int size = windowLines() * windowColumns();
if (_windowBuffer == 0 || _windowBufferSize != size)
{
delete[] _windowBuffer;
_windowBufferSize = size;
_windowBuffer = new Character[size];
_bufferNeedsUpdate = true;
}
// reallocate internal buffer if the window size has changed
int size = windowLines() * windowColumns();
if (_windowBuffer == 0 || _windowBufferSize != size) {
delete[] _windowBuffer;
_windowBufferSize = size;
_windowBuffer = new Character[size];
_bufferNeedsUpdate = true;
}
if (!_bufferNeedsUpdate)
return _windowBuffer;
_screen->getImage(_windowBuffer,size,
currentLine(),endWindowLine());
if (!_bufferNeedsUpdate)
return _windowBuffer;
// this window may look beyond the end of the screen, in which
// case there will be an unused area which needs to be filled
// with blank characters
fillUnusedArea();
_screen->getImage(_windowBuffer,size,
currentLine(),endWindowLine());
_bufferNeedsUpdate = false;
return _windowBuffer;
// this window may look beyond the end of the screen, in which
// case there will be an unused area which needs to be filled
// with blank characters
fillUnusedArea();
_bufferNeedsUpdate = false;
return _windowBuffer;
}
void ScreenWindow::fillUnusedArea()
{
int screenEndLine = _screen->getHistLines() + _screen->getLines() - 1;
int windowEndLine = currentLine() + windowLines() - 1;
int screenEndLine = _screen->getHistLines() + _screen->getLines() - 1;
int windowEndLine = currentLine() + windowLines() - 1;
int unusedLines = windowEndLine - screenEndLine;
int charsToFill = unusedLines * windowColumns();
int unusedLines = windowEndLine - screenEndLine;
int charsToFill = unusedLines * windowColumns();
Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill);
Screen::fillWithDefaultChar(_windowBuffer + _windowBufferSize - charsToFill,charsToFill);
}
// return the index of the line at the end of this window, or if this window
// return the index of the line at the end of this window, or if this window
// goes beyond the end of the screen, the index of the line at the end
// of the screen.
//
@@ -104,17 +103,17 @@ void ScreenWindow::fillUnusedArea()
//
int ScreenWindow::endWindowLine() const
{
return qMin(currentLine() + windowLines() - 1,
lineCount() - 1);
return qMin(currentLine() + windowLines() - 1,
lineCount() - 1);
}
QVector<LineProperty> ScreenWindow::getLineProperties()
{
QVector<LineProperty> result = _screen->getLineProperties(currentLine(),endWindowLine());
if (result.count() != windowLines())
result.resize(windowLines());
return result;
if (result.count() != windowLines())
result.resize(windowLines());
return result;
}
QString ScreenWindow::selectedText( bool preserveLineBreaks ) const
@@ -135,8 +134,8 @@ void ScreenWindow::getSelectionEnd( int& column , int& line )
void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )
{
_screen->setSelectionStart( column , qMin(line + currentLine(),endWindowLine()) , columnMode);
_bufferNeedsUpdate = true;
_bufferNeedsUpdate = true;
emit selectionChanged();
}
@@ -144,7 +143,7 @@ void ScreenWindow::setSelectionEnd( int column , int line )
{
_screen->setSelectionEnd( column , qMin(line + currentLine(),endWindowLine()) );
_bufferNeedsUpdate = true;
_bufferNeedsUpdate = true;
emit selectionChanged();
}
@@ -162,12 +161,12 @@ void ScreenWindow::clearSelection()
void ScreenWindow::setWindowLines(int lines)
{
Q_ASSERT(lines > 0);
_windowLines = lines;
Q_ASSERT(lines > 0);
_windowLines = lines;
}
int ScreenWindow::windowLines() const
{
return _windowLines;
return _windowLines;
}
int ScreenWindow::windowColumns() const
@@ -188,11 +187,11 @@ int ScreenWindow::columnCount() const
QPoint ScreenWindow::cursorPosition() const
{
QPoint position;
position.setX( _screen->getCursorX() );
position.setY( _screen->getCursorY() );
return position;
return position;
}
int ScreenWindow::currentLine() const
@@ -202,13 +201,10 @@ int ScreenWindow::currentLine() const
void ScreenWindow::scrollBy( RelativeScrollMode mode , int amount )
{
if ( mode == ScrollLines )
{
if ( mode == ScrollLines ) {
scrollTo( currentLine() + amount );
}
else if ( mode == ScrollPages )
{
scrollTo( currentLine() + amount * ( windowLines() / 2 ) );
} else if ( mode == ScrollPages ) {
scrollTo( currentLine() + amount * ( windowLines() / 2 ) );
}
}
@@ -219,8 +215,8 @@ bool ScreenWindow::atEndOfOutput() const
void ScreenWindow::scrollTo( int line )
{
int maxCurrentLineNumber = lineCount() - windowLines();
line = qBound(0,line,maxCurrentLineNumber);
int maxCurrentLineNumber = lineCount() - windowLines();
line = qBound(0,line,maxCurrentLineNumber);
const int delta = line - _currentLine;
_currentLine = line;
@@ -249,48 +245,45 @@ int ScreenWindow::scrollCount() const
return _scrollCount;
}
void ScreenWindow::resetScrollCount()
void ScreenWindow::resetScrollCount()
{
_scrollCount = 0;
}
QRect ScreenWindow::scrollRegion() const
{
bool equalToScreenSize = windowLines() == _screen->getLines();
bool equalToScreenSize = windowLines() == _screen->getLines();
if ( atEndOfOutput() && equalToScreenSize )
return _screen->lastScrolledRegion();
else
return QRect(0,0,windowColumns(),windowLines());
if ( atEndOfOutput() && equalToScreenSize )
return _screen->lastScrolledRegion();
else
return QRect(0,0,windowColumns(),windowLines());
}
void ScreenWindow::notifyOutputChanged()
{
// move window to the bottom of the screen and update scroll count
// if this window is currently tracking the bottom of the screen
if ( _trackOutput )
{
if ( _trackOutput ) {
_scrollCount -= _screen->scrolledLines();
_currentLine = qMax(0,_screen->getHistLines() - (windowLines()-_screen->getLines()));
}
else
{
// if the history is not unlimited then it may
} else {
// if the history is not unlimited then it may
// have run out of space and dropped the oldest
// lines of output - in this case the screen
// window's current line number will need to
// window's current line number will need to
// be adjusted - otherwise the output will scroll
_currentLine = qMax(0,_currentLine -
_screen->droppedLines());
_currentLine = qMax(0,_currentLine -
_screen->droppedLines());
// ensure that the screen window's current position does
// not go beyond the bottom of the screen
_currentLine = qMin( _currentLine , _screen->getHistLines() );
}
_bufferNeedsUpdate = true;
_bufferNeedsUpdate = true;
emit outputChanged();
emit outputChanged();
}
//#include "moc_ScreenWindow.cpp"