Commit d746c96c authored by Robert Knight's avatar Robert Knight

* New approach to handling scrolling views on the same session

  independantly.  Added ScreenWindow class which represents a window
  onto a terminal screen.  Each terminal view has one screen window
  associated with it.

  This breaks the original design choice of not having the view know anything
  about the session it was displaying, but I feel that no longer makes 
  sense when there is more than one view on a session.

  Still work-in-progress

* Add methods to support tooltips in filters

* Add start of new history size dialog which I hope is easier to understand.

* Internal renaming for clarity
	ca 	-> Character
	cacol	-> CharacterColor
	CO_XYZ	-> COLOR_SPACE_XYZ
	ca.c	-> ca.character
	ca.r	-> ca.rendition
	ca.f 	-> ca.foregroundColor
	ca.b	-> ca.backgroundColor


svn path=/branches/work/konsole-split-view/; revision=640688
parent d78fb4a0
......@@ -64,6 +64,7 @@ set(konsole_KDEINIT_SRCS
KonsoleBookmarkHandler.cpp
KonsoleMainWindow.cpp
ProcessInfo.cpp
ScreenWindow.cpp
SessionController.cpp
SessionList.cpp
SessionListWidget.cpp
......@@ -86,6 +87,8 @@ set(konsole_KDEINIT_SRCS
start.cpp
)
set_source_files_properties(${konsole_KDEINIT_SRCS} PROPERTIES COMPILE_FLAGS "-Wuninitialized")
kde4_automoc(${konsole_KDEINIT_SRCS})
kde4_add_kdeinit_executable( konsole ${konsole_KDEINIT_SRCS})
......@@ -126,8 +129,11 @@ set(konsolepart_PART_SRCS
KeyTrans.cpp
TerminalCharacterDecoder.cpp
SessionManager.cpp
ScreenWindow.cpp
Filter.cpp )
set_source_files_properties(${konsolepart_PART_SRCS} PROPERTIES COMPILE_FLAGS -Wuninitialized)
kde4_automoc(${konsolepart_PART_SRCS})
......
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2007 by Robert Knight <robertknight@gmail.characterom>
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
......@@ -111,7 +111,7 @@ QList<Filter::HotSpot*> FilterChain::hotSpots() const
}
//QList<Filter::HotSpot*> FilterChain::hotSpotsAtLine(int line) const;
void TerminalImageFilterChain::addImage(const ca* const image , int lines , int columns)
void TerminalImageFilterChain::addImage(const Character* const image , int lines , int columns)
{
if (empty())
return;
......@@ -228,6 +228,10 @@ Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int end
, _type(NotSpecified)
{
}
QString Filter::HotSpot::tooltip() const
{
return QString();
}
QList<QAction*> Filter::HotSpot::actions()
{
return QList<QAction*>();
......@@ -350,6 +354,12 @@ UrlFilter::HotSpot::HotSpot(int startLine,int startColumn,int endLine,int endCol
{
setType(Link);
}
QString UrlFilter::HotSpot::tooltip() const
{
QString url = capturedTexts().first();
return i18n("Click to open '%1' in your browser.",url);
}
void UrlFilter::HotSpot::activate()
{
const QStringList& texts = capturedTexts();
......
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2007 by Robert Knight <robertknight@gmail.characterom>
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
......@@ -27,7 +27,7 @@
#include <QMultiHash>
#include <QRegExp>
class ca;
class Character;
/**
* A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)
......@@ -100,6 +100,14 @@ public:
/** Returns a list of actions associated with the hotspot which can be used in a menu or toolbar */
virtual QList<QAction*> actions();
/**
* Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or
* an empty string if there is no tooltip associated with this hotspot.
*
* The default implementation returns an empty string.
*/
virtual QString tooltip() const;
protected:
/** Sets the type of a hotspot. This should only be set once */
void setType(Type type);
......@@ -225,6 +233,8 @@ public:
* the capturedTexts() method.
*/
virtual void activate();
virtual QString tooltip() const;
private:
FilterObject* _urlObject;
};
......@@ -310,6 +320,6 @@ public:
* @param lines The number of lines in the terminal image
* @param columns The number of columns in the terminal image
*/
void addImage(const ca* const image , int lines , int columns);
void addImage(const Character* const image , int lines , int columns);
};
#endif //FILTER_H
/*
Copyright 2007 by Robert Knight <robertknight@gmail.characterom>
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// Qt
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QWidget>
// KDE
#include <KLocalizedString>
// Konsole
#include "HistorySizeDialog.h"
HistorySizeDialog::HistorySizeDialog( QWidget* parent )
: KDialog(parent)
, _mode( FixedSizeHistory )
, _lineCount( 1000 )
{
// basic dialog properties
setPlainCaption( i18n("History Options") );
setButtons( Default | Ok | Cancel );
setDefaultButton(Ok);
setModal( true );
// dialog widgets
QWidget* dialogWidget = new QWidget(this);
setMainWidget(dialogWidget);
QVBoxLayout* dialogLayout = new QVBoxLayout(dialogWidget);
QButtonGroup* modeGroup = new QButtonGroup(this);
QRadioButton* noHistoryButton = new QRadioButton( i18n("No History") );
QRadioButton* fixedHistoryButton = new QRadioButton( i18n("Fixed Size History") );
QRadioButton* unlimitedHistoryButton = new QRadioButton( i18n("Unlimited History") );
modeGroup->addButton(noHistoryButton);
modeGroup->addButton(fixedHistoryButton);
modeGroup->addButton(unlimitedHistoryButton);
QSpinBox* lineCountBox = new QSpinBox(this);
// minimum lines = 1 ( for 0 lines , "No History" mode should be used instead )
// maximum lines is abritrarily chosen, I do not think it is sensible to allow this
// to be set to a very large figure because that will use large amounts of memory,
// if a very large log is required, "Unlimited History" mode should be used
lineCountBox->setRange( 1 , 100000 );
// 1000 lines was the default in the KDE 3 series
// using that for now
lineCountBox->setValue( 1000 );
QLabel* lineCountLabel = new QLabel(i18n("lines"),this);
QHBoxLayout* lineCountLayout = new QHBoxLayout();
fixedHistoryButton->setFocusProxy(lineCountBox);
connect( fixedHistoryButton , SIGNAL(clicked()) , lineCountBox , SLOT(selectAll()) );
lineCountLayout->addWidget(fixedHistoryButton);
lineCountLayout->addWidget(lineCountBox);
lineCountLayout->addWidget(lineCountLabel);
dialogLayout->addWidget(noHistoryButton);
dialogLayout->addLayout(lineCountLayout);
dialogLayout->addWidget(unlimitedHistoryButton);
// select the fixed size mode by default
fixedHistoryButton->click();
fixedHistoryButton->setFocus( Qt::OtherFocusReason );
}
void HistorySizeDialog::setMode( HistoryMode mode )
{
_mode = mode;
}
HistorySizeDialog::HistoryMode HistorySizeDialog::mode() const
{
return _mode;
}
int HistorySizeDialog::lineCount() const
{
return _lineCount;
}
void HistorySizeDialog::setLineCount(int lines)
{
_lineCount = lines;
}
#include "HistorySizeDialog.moc"
/*
Copyright 2007 by Robert Knight <robertknight@gmail.characterom>
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef HISTORYSIZEDIALOG_H
#define HISTORYSIZEDIALOG_H
// KDE
#include <KDialog>
/**
* A dialog which allows the user to select the number of lines of output
* which are remembered for a session.
*/
class HistorySizeDialog : public KDialog
{
Q_OBJECT
public:
/**
* Construct a new history size dialog.
*/
HistorySizeDialog( QWidget* parent );
/** Specifies the type of history scroll */
enum HistoryMode
{
/**
* No history. Lines of output are lost
* as soon as they are scrolled off-screen.
*/
NoHistory,
/**
* A history which stores up to a fixed number of lines
* in memory.
*/
FixedSizeHistory,
/**
* An 'unlimited' history which stores lines of output in
* a file on disk.
*/
UnlimitedHistory
};
/** Specifies the history mode. */
void setMode( HistoryMode mode );
/** Returns the history mode chosen by the user. */
HistoryMode mode() const;
/**
* Returns the number of lines of history to remember.
* This is only valid when mode() == FixedSizeHistory,
* and returns 0 otherwise.
*/
int lineCount() const;
/** Sets the number of lines for the fixed size history mode. */
void setLineCount(int lines);
private:
HistoryMode _mode;
int _lineCount;
};
#endif // HISTORYSIZEDIALOG_H
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......@@ -71,7 +71,7 @@ IncrementalSearchBar::IncrementalSearchBar(Features features , QWidget* parent)
findNext->setObjectName("find-next-button");
findNext->setText(i18n("Next"));
findNext->setAutoRaise(true);
findNext->setIcon( KIcon("next") );
findNext->setIcon( KIcon("find-next") );
findNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
findNext->setToolTip("Find the next match for the current search phrase");
connect( findNext , SIGNAL(clicked()) , this , SIGNAL(findNextClicked()) );
......@@ -80,7 +80,7 @@ IncrementalSearchBar::IncrementalSearchBar(Features features , QWidget* parent)
findPrev->setObjectName("find-previous-button");
findPrev->setText(i18n("Previous"));
findPrev->setAutoRaise(true);
findPrev->setIcon( KIcon("previous") );
findPrev->setIcon( KIcon("find-previous") );
findPrev->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
findPrev->setToolTip("Find the previous match for the current search phrase");
connect( findPrev , SIGNAL(clicked()) , this , SIGNAL(findPreviousClicked()) );
......
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......
......@@ -765,7 +765,7 @@ void TestTokenizer(QBuffer &buf)
while (getSymbol(buf)) ReportToken();
buf.close();
buf.characterlose();
}
void test()
......
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......
/* This file was part of the KDE libraries
Copyright 2002 Carsten Pfeiffer <pfeiffer@kde.org>
Copyright 2007 Robert Knight <robertknight@gmail.com>
Copyright 2007 Robert Knight <robertknight@gmail.characterom>
library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -19,7 +19,7 @@
Boston, MA 02110-1301, USA.
*/
// Born as kdelibs/kio/kfile/kfilebookmarkhandler.cpp
// Born as kdelibs/kio/kfile/kfilebookmarkhandler.characterpp
// Qt
#include <QFile>
......
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......
/*
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.characterom>
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
......
/*
This file is part of Konsole, an X terminal.
Copyright (C) 2006 Robert Knight <robertknight@gmail.com>
Copyright (C) 2006 Robert Knight <robertknight@gmail.characterom>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
......@@ -54,7 +54,7 @@ void OverlayFrame::paintEvent(QPaintEvent* /*event*/)
QPalette palette = QApplication::palette();
QPainter painter;
painter.begin(this);
painter.backgroundColoregin(this);
//setup translucent background
QColor background = palette.color(QPalette::Window);
......@@ -70,7 +70,7 @@ void OverlayFrame::paintEvent(QPaintEvent* /*event*/)
int dx = (elapsed / 10);
gradient.setStart( area.left() + dx , area.top() );
gradient.setFinalStop( area.right() - dx , area.bottom() );
gradient.setFinalStop( area.renditionight() - dx , area.backgroundColorottom() );
QColor darkColor = palette.color(QPalette::Dark);
darkColor.setAlpha( opacity );
......
/*
This file is part of Konsole, an X terminal.
Copyright (C) 2006 Robert Knight <robertknight@gmail.com>
Copyright (C) 2006 Robert Knight <robertknight@gmail.characterom>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
......
/*
* This file is part of the KDE libraries
* Copyright (c) 2002 Michael Goffioul <kdeprint@swing.be>
* Copyright (c) 2002 Michael Goffioul <kdeprint@swing.backgroundColore>
* (c) 2003 Waldo Bastian <bastian@kde.org>
*
* This library is free software; you can redistribute it and/or
......
/*
* This file is part of the KDE libraries
* Copyright (c) 2002 Michael Goffioul <kdeprint@swing.be>
* Copyright (c) 2002 Michael Goffioul <kdeprint@swing.backgroundColore>
* Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
*
* This library is free software; you can redistribute it and/or
......
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2007 by Robert Knight <robertknight@gmail.countm>
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
......
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2007 by Robert Knight <robertknight@gmail.characterom>
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
......@@ -64,7 +64,7 @@
*
* if ( ok ) qDebug() << "parent process - " << parentPid;
*
* int foregroundPid = info.foregroundPid(&ok);
* int foregroundPid = info.foregroundColororegroundPid(&ok);
*
* if ( ok ) qDebug() << "foreground process - " << foregroundPid;
* }
......
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.characterom>
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// Qt
#include <QtDebug>
// Konsole
#include "TEScreen.h"
#include "ScreenWindow.h"
ScreenWindow::ScreenWindow()
: _currentLine(0)
, _trackOutput(true)
{
}
void ScreenWindow::setScreen(TEScreen* screen)
{
Q_ASSERT( _screen );
_screen = screen;
}
TEScreen* ScreenWindow::screen() const
{
return _screen;
}
Character* ScreenWindow::getImage()
{
return _screen->getCookedImage(_currentLine);
}
QVector<LineProperty> ScreenWindow::getLineProperties()
{
return _screen->getCookedLineProperties(_currentLine);
}
QString ScreenWindow::selectedText( bool preserveLineBreaks ) const
{
return _screen->selectedText( preserveLineBreaks );
}
void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )
{
/* FIXME - I'm not sure what the columnmode parameter ( the last argument to setSelectionStart )
does, check it out and fix */
_screen->setSelectionStart( column , line + _currentLine , columnMode);
}
void ScreenWindow::setSelectionEnd( int column , int line )
{
_screen->setSelectionEnd( column , line + _currentLine );
}
bool ScreenWindow::isSelected( int column , int line )
{
return _screen->isSelected( column , line + _currentLine );
}
void ScreenWindow::clearSelection()
{
_screen->clearSelection();
}
int ScreenWindow::windowLines() const
{
return _screen->getLines();
}
int ScreenWindow::windowColumns() const
{
return _screen->getColumns();
}
int ScreenWindow::lineCount() const
{
return _screen->getHistLines();
}
int ScreenWindow::columnCount() const
{
return _screen->getColumns();
}
int ScreenWindow::currentLine() const
{
return _currentLine;
}
void ScreenWindow::scrollTo( int line )
{
const int delta = line - _currentLine;
_currentLine = line;
// keep track of number of lines scrolled by,
// this can be reset by calling resetScrollCount()
_scrollCount += delta;
}
void ScreenWindow::setTrackOutput(bool trackOutput)
{
_trackOutput = trackOutput;
}
bool ScreenWindow::trackOutput() const
{
return _trackOutput;
}
int ScreenWindow::scrollCount() const
{
return _scrollCount;
}
void ScreenWindow::resetScrollCount()
{
_scrollCount = 0;
}
/*
Copyright (C) 2007 by Robert Knight <robertknight@gmail.characterom>
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef SCREENWINDOW_H
#define SCREENWINDOW_H
// Qt
#include <QObject>
class TEScreen;
/**
* Provides a window onto a section of a terminal screen.
* This window can then be rendered by a terminal display widget ( TEWidget ).
*
*/
class ScreenWindow //: public QObject