Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving using up/down keys #94

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fa53ac2
Implement a more natural behaviour for Key_Up and Key_Down
Pac72 Sep 2, 2015
1766900
Emit newSelection() signal when changing selection with the keyboard
Pac72 Sep 3, 2015
b99c494
Make options dialog layout friendly to window resize
variar Mar 9, 2016
35b21a3
Make general tab default one
variar Mar 9, 2016
1a2fec1
Use atomic operations to set interrupt and terminate flags
variar Mar 9, 2016
7916896
Fix indentation
variar Mar 9, 2016
3b10469
Add option to not load last session
variar Mar 10, 2016
5f5b86a
Use file settings in programm dir before system specific settings places
variar Mar 14, 2016
47a22ef
Merge branch 'load_last_session_option' into dev
variar Mar 14, 2016
f9fe502
Merge branch 'portable' into dev
variar Mar 14, 2016
0f8328b
Make native file watching optional via CONFIG qmake variable
variar Mar 15, 2016
07557af
Add missing includes
variar Mar 15, 2016
d29d1a9
Use Qt atomic for portability (mingw without pthreads case)
variar Mar 15, 2016
1d82537
Use QString for filenames
variar Mar 15, 2016
a79e227
Fix view_context to QString formatting
variar Mar 15, 2016
26adf4b
Fix some compiler warnings
variar Mar 15, 2016
955c213
Allow to get git version in shadow builds
variar Mar 15, 2016
22f22cf
Allow multiple files in qt-based file watcher
variar Mar 15, 2016
3bf7dbb
Restore selected line in filter view after new search
variar Mar 16, 2016
43a7b9e
Keep selected line when switching filtered view visibility
variar Mar 16, 2016
e1d543d
Use lower_bound in case there is no exact match for line number
variar Mar 16, 2016
340cd8d
Make marks selection lookup logarithmic
variar Mar 16, 2016
b9c9a81
Add ignore case option to filters
variar Mar 17, 2016
999dff6
Update README
variar Mar 18, 2016
e02bd1b
Merge branch 'case_insensitive_filter'
variar Mar 18, 2016
14b5111
Switch from deprecated QRegExp to QRegularExpression
variar Mar 21, 2016
bdb4b9e
Use Qt threading and mutex for portability
variar Mar 21, 2016
3eee570
Allow to limit file search area
variar Apr 4, 2016
893faa0
Fix search limits selection
variar Apr 18, 2016
6541409
Make quicksearch hotkeys more numpad friendly
variar Apr 18, 2016
0852d82
Use local socket base implementation of external communicator on windows
variar Apr 23, 2016
a13b386
Fix pro
variar Apr 23, 2016
39d98e3
Merge with upstream v1.1.0
variar Apr 25, 2016
16be497
Add support for multibyte utf encoding auto detection
variar Apr 25, 2016
0610721
Override auto-detected encoding from menu
variar May 1, 2016
5f2cbf2
Fix build
variar May 1, 2016
bca3f86
Fix setting foreground window on Win32
variar May 17, 2016
b1ff2a9
Add one more line to vertical scroll area
variar May 18, 2016
c724453
Implement a more natural behaviour for Key_Up and Key_Down
Pac72 Sep 2, 2015
7fc76d9
Emit newSelection() signal when changing selection with the keyboard
Pac72 Sep 3, 2015
7c390b8
Merge upstream changes.
Pac72 Jul 8, 2016
1c88db9
Implement a more natural behaviour for Key_Up and Key_Down
Pac72 Sep 2, 2015
4310c4b
Emit newSelection() signal when changing selection with the keyboard
Pac72 Sep 3, 2015
dc8eec0
Fix compilation with Qt 5.2.1
Pac72 Jul 11, 2016
fe9bc1c
Merge branch 'master' of github.com:Pac72/glogg
Pac72 Jul 11, 2016
d9128d2
If file cannot be opened, clear indexing_data. Otherwise, if the file
Pac72 Jul 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
glogg - the fast, smart log explorer
klogg is the fork of glogg - the fast, smart log explorer

The main reason for this fork is that we use glogg a lot
and feel that usability can be improved here and there

## Features of klogg
* Support for non-latin simbols in file paths
* Keeps selected lines visible after changing search pattern

## About glogg

glogg is a multi-platform GUI application that helps browse and search
through long and complex log files. It is designed with programmers and
Expand Down
93 changes: 53 additions & 40 deletions glogg.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
TARGET = glogg
TEMPLATE = app

QT += network

greaterThan(QT_MAJOR_VERSION, 4): QT += core widgets

win32:Debug:CONFIG += console
Expand Down Expand Up @@ -50,8 +52,7 @@ SOURCES += \
src/quickfindmux.cpp \
src/signalmux.cpp \
src/tabbedcrawlerwidget.cpp \
src/viewtools.cpp \
src/encodingspeculator.cpp \
src/viewtools.cpp

INCLUDEPATH += src/

Expand All @@ -61,6 +62,9 @@ HEADERS += \
src/data/logfiltereddata.h \
src/data/logfiltereddataworkerthread.h \
src/data/logdataworkerthread.h \
src/data/threadprivatestore.h \
src/data/compressedlinestorage.h \
src/data/linepositionarray.h \
src/mainwindow.h \
src/session.h \
src/viewinterface.h \
Expand Down Expand Up @@ -95,7 +99,7 @@ HEADERS += \
src/loadingstatus.h \
src/externalcom.h \
src/viewtools.h \
src/encodingspeculator.h \
src/data/atomicflag.h

isEmpty(BOOST_PATH) {
message(Building using system dynamic Boost libraries)
Expand Down Expand Up @@ -180,24 +184,24 @@ OBJECTS_DIR = $${OUT_PWD}/.obj/$${DESTDIR}-shared
MOC_DIR = $${OUT_PWD}/.moc/$${DESTDIR}-shared
UI_DIR = $${OUT_PWD}/.ui/$${DESTDIR}-shared

# Debug symbols even in release build
QMAKE_CXXFLAGS = -g

# Which compiler are we using
system( $${QMAKE_CXX} --version | grep -e " 4\\.[7-9]" ) || macx {
message ( "g++ version 4.7 or newer, supports C++11" )
CONFIG += C++11
}
else {
CONFIG += C++0x
}
#system( $${QMAKE_CXX} --version | grep -e " 4\\.[7-9]" ) || macx {
# message ( "g++ version 4.7 or newer, supports C++11" )
# CONFIG += C++11
#}
#else {
# CONFIG += C++0x
#}

# Extra compiler arguments
# QMAKE_CXXFLAGS += -Weffc++
QMAKE_CXXFLAGS += -Wextra
C++0x:QMAKE_CXXFLAGS += -std=c++0x
C++11:QMAKE_CXXFLAGS += -std=c++11

#QMAKE_CXXFLAGS += -Wextra
#C++0x:QMAKE_CXXFLAGS += -std=c++0x
#C++11:QMAKE_CXXFLAGS += -std=c++11
CONFIG += c++11
#release:QMAKE_CXXFLAGS += -O2
# Debug symbols even in release build
QMAKE_CXXFLAGS += -g
GPROF {
QMAKE_CXXFLAGS += -pg
QMAKE_LFLAGS += -pg
Expand Down Expand Up @@ -227,8 +231,8 @@ isEmpty(VERSION):system(date >/dev/null) {
}
else {
QMAKE_CXXFLAGS += -DGLOGG_DATE=\\\"`date +'\"%F\"'`\\\"
QMAKE_CXXFLAGS += -DGLOGG_VERSION=\\\"`git describe`\\\"
QMAKE_CXXFLAGS += -DGLOGG_COMMIT=\\\"`git rev-parse --short HEAD`\\\"
QMAKE_CXXFLAGS += -DGLOGG_VERSION=\\\"`git --git-dir=$$PWD/.git describe`\\\"
QMAKE_CXXFLAGS += -DGLOGG_COMMIT=\\\"`git --git-dir=$$PWD/.git rev-parse --short HEAD`\\\"
}
}
else {
Expand All @@ -246,10 +250,10 @@ system(pkg-config --exists QtDBus):!no-dbus {
else {
message("Support for D-BUS will NOT be included")
win32 {
message("Support for Windows IPC will be included")
message("Support for cross-platform IPC will be included")
QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_WINIPC
SOURCES += src/winexternalcom.cpp
HEADERS += src/winexternalcom.h
SOURCES += src/socketexternalcom.cpp
HEADERS += src/socketexternalcom.h
}
}

Expand All @@ -265,28 +269,37 @@ else {
message("Version checker will NOT be included")
}

# File watching
linux-g++ || linux-g++-64 {
CONFIG += inotify
}

win32 {
message("File watching using Windows")
SOURCES += src/platformfilewatcher.cpp src/winwatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
HEADERS += src/platformfilewatcher.h src/winwatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_POLLING
# File watching (e.g. CONFIG+=no-native-filewatch)
no-native-filewatch {
message("File watching using Qt")
QMAKE_CXXFLAGS += -DGLOGG_USES_QTFILEWATCHER
SOURCES += src/qtfilewatcher.cpp
HEADERS += src/qtfilewatcher.h
}
else {
inotify {
message("File watching using inotify")
QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_INOTIFY
SOURCES += src/platformfilewatcher.cpp src/inotifywatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
HEADERS += src/platformfilewatcher.h src/inotifywatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
linux-g++ || linux-g++-64 {
CONFIG += inotify
}

win32 {
message("File watching using Windows")
SOURCES += src/platformfilewatcher.cpp src/winwatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
HEADERS += src/platformfilewatcher.h src/winwatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_POLLING
}
else {
message("File watching using Qt")
SOURCES += src/qtfilewatcher.cpp
HEADERS += src/qtfilewatcher.h
inotify {
message("File watching using inotify")
QMAKE_CXXFLAGS += -DGLOGG_SUPPORTS_INOTIFY
SOURCES += src/platformfilewatcher.cpp src/inotifywatchtowerdriver.cpp src/watchtower.cpp src/watchtowerlist.cpp
HEADERS += src/platformfilewatcher.h src/inotifywatchtowerdriver.h src/watchtower.h src/watchtowerlist.h
}
else {
message("File watching using Qt")
QMAKE_CXXFLAGS += -DGLOGG_USES_QTFILEWATCHER
SOURCES += src/qtfilewatcher.cpp
HEADERS += src/qtfilewatcher.h
}
}
}

Expand Down
110 changes: 93 additions & 17 deletions src/abstractlogview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@ AbstractLogView::AbstractLogView(const AbstractLogData* newLogData,
selectionCurrentEndPos_(),
autoScrollTimer_(),
selection_(),
searchStart_(),
quickFindPattern_( quickFindPattern ),
quickFind_( newLogData, &selection_, quickFindPattern )
{
logData = newLogData;
searchEnd_ = logData->getNbLine();

followMode_ = false;

Expand Down Expand Up @@ -360,10 +362,16 @@ void AbstractLogView::mousePressEvent( QMouseEvent* mouseEvent )
// Prepare the popup depending on selection type
if ( selection_.isSingleLine() ) {
copyAction_->setText( "&Copy this line" );

setSearchStartAction_->setEnabled( true );
setSearchEndAction_->setEnabled( true );
}
else {
copyAction_->setText( "&Copy" );
copyAction_->setStatusTip( tr("Copy the selection") );

setSearchStartAction_->setEnabled( false );
setSearchEndAction_->setEnabled( false );
}

if ( selection_.isPortion() ) {
Expand Down Expand Up @@ -513,13 +521,33 @@ void AbstractLogView::timerEvent( QTimerEvent* timerEvent )
QAbstractScrollArea::timerEvent( timerEvent );
}

void AbstractLogView::moveSelectionAndEmit(int delta) {
disableFollow();
moveSelection( delta );
emit newSelection( selection_.selectedLine() );
}

void AbstractLogView::moveSelectionUp() {
int delta = qMin( -1, - digitsBuffer_.content() );
moveSelectionAndEmit(delta);
}

void AbstractLogView::moveSelectionDown() {
int delta = qMax( 1, digitsBuffer_.content() );
moveSelectionAndEmit(delta);
}

void AbstractLogView::keyPressEvent( QKeyEvent* keyEvent )
{
LOG(logDEBUG4) << "keyPressEvent received";
bool controlModifier = (keyEvent->modifiers() & Qt::ControlModifier) == Qt::ControlModifier;
bool shiftModifier = (keyEvent->modifiers() & Qt::ShiftModifier) == Qt::ShiftModifier;

if ( keyEvent->key() == Qt::Key_Left )
if ( keyEvent->key() == Qt::Key_Up)
moveSelectionUp();
else if ( keyEvent->key() == Qt::Key_Down)
moveSelectionDown();
else if ( keyEvent->key() == Qt::Key_Left )
horizontalScrollBar()->triggerAction(QScrollBar::SliderPageStepSub);
else if ( keyEvent->key() == Qt::Key_Right )
horizontalScrollBar()->triggerAction(QScrollBar::SliderPageStepAdd);
Expand Down Expand Up @@ -558,20 +586,12 @@ void AbstractLogView::keyPressEvent( QKeyEvent* keyEvent )
switch ( (keyEvent->text())[0].toLatin1() ) {
case 'j':
{
int delta = qMax( 1, digitsBuffer_.content() );
disableFollow();
//verticalScrollBar()->triggerAction(
//QScrollBar::SliderSingleStepAdd);
moveSelection( delta );
moveSelectionDown();
break;
}
case 'k':
{
int delta = qMin( -1, - digitsBuffer_.content() );
disableFollow();
//verticalScrollBar()->triggerAction(
//QScrollBar::SliderSingleStepSub);
moveSelection( delta );
moveSelectionUp();
break;
}
case 'h':
Expand Down Expand Up @@ -614,7 +634,7 @@ void AbstractLogView::keyPressEvent( QKeyEvent* keyEvent )
// Use the selected 'word' and search forward
findNextSelected();
break;
case '#':
case '/':
// Use the selected 'word' and search backward
findPreviousSelected();
break;
Expand Down Expand Up @@ -816,6 +836,11 @@ qint64 AbstractLogView::displayLineNumber( int lineNumber ) const
return lineNumber + 1; // show a 1-based index
}

qint64 AbstractLogView::lineIndex( int lineNumber ) const
{
return lineNumber;
}

qint64 AbstractLogView::maxDisplayLineNumber() const
{
return logData->getNbLine();
Expand Down Expand Up @@ -958,6 +983,27 @@ void AbstractLogView::copy()
clipboard->setText( selection_.getSelectedText( logData ) );
}

void AbstractLogView::updateSearchLimits()
{
textAreaCache_.invalid_ = true;
update();

emit changeSearchLimits(displayLineNumber(searchStart_) - 1,
displayLineNumber(searchEnd_) - 1);
}

void AbstractLogView::setSearchStart()
{
searchStart_ = selection_.selectedLine();
updateSearchLimits();
}

void AbstractLogView::setSearchEnd()
{
searchEnd_ = selection_.selectedLine() + 1;
updateSearchLimits();
}

//
// Public functions
//
Expand Down Expand Up @@ -994,10 +1040,7 @@ void AbstractLogView::updateData()
if ( overview_ != NULL )
overview_->updateCurrentPosition( firstLine, last_line );

// Invalidate our cache
textAreaCache_.invalid_ = true;

// Repaint!
update();
}

Expand Down Expand Up @@ -1082,6 +1125,15 @@ void AbstractLogView::forceRefresh()
textAreaCache_.invalid_ = true;
}

void AbstractLogView::setSearchLimits( qint64 startLine, qint64 endLine )
{
searchStart_ = lineIndex( startLine );
searchEnd_ = lineIndex( endLine );

textAreaCache_.invalid_ = true;
update();
}

//
// Private functions
//
Expand Down Expand Up @@ -1320,12 +1372,29 @@ void AbstractLogView::createMenu()
connect( addToSearchAction_, SIGNAL( triggered() ),
this, SLOT( addToSearch() ) );

setSearchStartAction_ = new QAction( tr("Set search start"), this );
connect( setSearchStartAction_, SIGNAL( triggered() ),
this, SLOT( setSearchStart() ) );

setSearchEndAction_ = new QAction( tr("Set search end"), this );
connect( setSearchEndAction_, SIGNAL( triggered() ),
this, SLOT( setSearchEnd() ) );

clearSearchLimitAction_ = new QAction( tr("Clear search limit"), this );
connect( clearSearchLimitAction_, SIGNAL( triggered() ),
this, SIGNAL( clearSearchLimits() ) );

popupMenu_ = new QMenu( this );
popupMenu_->addAction( copyAction_ );
popupMenu_->addSeparator();
popupMenu_->addAction( findNextAction_ );
popupMenu_->addAction( findPreviousAction_ );
popupMenu_->addAction( addToSearchAction_ );
popupMenu_->addSeparator();
popupMenu_->addAction( setSearchStartAction_ );
popupMenu_->addAction( setSearchEndAction_ );
popupMenu_->addAction( clearSearchLimitAction_ );

}

void AbstractLogView::considerMouseHovering( int x_pos, int y_pos )
Expand Down Expand Up @@ -1353,7 +1422,7 @@ void AbstractLogView::considerMouseHovering( int x_pos, int y_pos )
void AbstractLogView::updateScrollBars()
{
verticalScrollBar()->setRange( 0, std::max( 0LL,
logData->getNbLine() - getNbVisibleLines() ) );
logData->getNbLine() - getNbVisibleLines() + 1 ) );

const int hScrollMaxValue = std::max( 0,
logData->getMaxLength() - getNbVisibleCols() + 1 );
Expand Down Expand Up @@ -1485,7 +1554,14 @@ void AbstractLogView::drawTextArea( QPaintDevice* paint_device, int32_t delta_y
}
else {
// Use the default colors
foreColor = palette.color( QPalette::Text );
if ( line_index < searchStart_ ||
line_index >= searchEnd_ ) {
foreColor = palette.brush( QPalette::Disabled, QPalette::Text ).color();
}
else {
foreColor = palette.color( QPalette::Text );
}

backColor = palette.color( QPalette::Base );
}

Expand Down
Loading