mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
jump to given line when activating a location list item
This commit is contained in:
parent
0e41597798
commit
5c78eac179
@ -24,6 +24,7 @@ namespace vnotex
|
|||||||
bool m_readOnly = false;
|
bool m_readOnly = false;
|
||||||
|
|
||||||
// If m_lineNumber > -1, it indicates the line to scroll to after opening the file.
|
// If m_lineNumber > -1, it indicates the line to scroll to after opening the file.
|
||||||
|
// 0-based.
|
||||||
int m_lineNumber = -1;
|
int m_lineNumber = -1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ namespace vnotex
|
|||||||
|
|
||||||
QString m_displayPath;
|
QString m_displayPath;
|
||||||
|
|
||||||
|
// 0-based.
|
||||||
int m_lineNumber = -1;
|
int m_lineNumber = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ namespace vnotex
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0-based.
|
||||||
int m_lineNumber = -1;
|
int m_lineNumber = -1;
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
@ -87,7 +87,7 @@ void FileSearchEngineWorker::searchFile(const QString &p_filePath, const QString
|
|||||||
|
|
||||||
QSharedPointer<SearchResultItem> resultItem;
|
QSharedPointer<SearchResultItem> resultItem;
|
||||||
|
|
||||||
int lineNum = 1;
|
int lineNum = 0;
|
||||||
QTextStream ins(&file);
|
QTextStream ins(&file);
|
||||||
while (!ins.atEnd()) {
|
while (!ins.atEnd()) {
|
||||||
if (isAskedToStop()) {
|
if (isAskedToStop()) {
|
||||||
|
@ -276,7 +276,7 @@ bool Searcher::searchContent(const File *p_file)
|
|||||||
|
|
||||||
QSharedPointer<SearchResultItem> resultItem;
|
QSharedPointer<SearchResultItem> resultItem;
|
||||||
|
|
||||||
int lineNum = 1;
|
int lineNum = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int contentSize = content.size();
|
int contentSize = content.size();
|
||||||
QRegularExpression newlineRegExp("\\n|\\r\\n|\\r");
|
QRegularExpression newlineRegExp("\\n|\\r\\n|\\r");
|
||||||
|
@ -138,7 +138,7 @@ void MarkdownViewerAdapter::scrollToLine(int p_lineNumber)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_topLineNumber = -1;
|
m_topLineNumber = p_lineNumber;
|
||||||
emit editLineNumberUpdated(p_lineNumber);
|
emit editLineNumberUpdated(p_lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ void LocationList::setItemLocationLineAndText(QTreeWidgetItem *p_item, const Com
|
|||||||
{
|
{
|
||||||
p_item->setData(Columns::LineColumn, Qt::UserRole, p_line.m_lineNumber);
|
p_item->setData(Columns::LineColumn, Qt::UserRole, p_line.m_lineNumber);
|
||||||
if (p_line.m_lineNumber != -1) {
|
if (p_line.m_lineNumber != -1) {
|
||||||
p_item->setText(Columns::LineColumn, QString::number(p_line.m_lineNumber));
|
p_item->setText(Columns::LineColumn, QString::number(p_line.m_lineNumber + 1));
|
||||||
}
|
}
|
||||||
p_item->setText(Columns::TextColumn, p_line.m_text);
|
p_item->setText(Columns::TextColumn, p_line.m_text);
|
||||||
}
|
}
|
||||||
|
@ -918,3 +918,10 @@ bool MarkdownViewWindow::isReadMode() const
|
|||||||
{
|
{
|
||||||
return m_mode == ViewWindowMode::Read;
|
return m_mode == ViewWindowMode::Read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkdownViewWindow::openTwice(const QSharedPointer<FileOpenParameters> &p_paras)
|
||||||
|
{
|
||||||
|
qDebug() << p_paras->m_lineNumber;
|
||||||
|
Q_ASSERT(!p_paras || !p_paras->m_newFile);
|
||||||
|
handleFileOpenParameters(p_paras);
|
||||||
|
}
|
||||||
|
@ -38,6 +38,8 @@ namespace vnotex
|
|||||||
|
|
||||||
QSharedPointer<OutlineProvider> getOutlineProvider() Q_DECL_OVERRIDE;
|
QSharedPointer<OutlineProvider> getOutlineProvider() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void openTwice(const QSharedPointer<FileOpenParameters> &p_paras) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <core/vnotex.h>
|
#include <core/vnotex.h>
|
||||||
#include <core/thememgr.h>
|
#include <core/thememgr.h>
|
||||||
#include "editors/statuswidget.h"
|
#include "editors/statuswidget.h"
|
||||||
|
#include <core/fileopenparameters.h>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -76,6 +77,8 @@ void TextViewWindow::handleBufferChangedInternal(const QSharedPointer<FileOpenPa
|
|||||||
{
|
{
|
||||||
Q_UNUSED(p_paras);
|
Q_UNUSED(p_paras);
|
||||||
TextViewWindowHelper::handleBufferChanged(this);
|
TextViewWindowHelper::handleBufferChanged(this);
|
||||||
|
|
||||||
|
handleFileOpenParameters(p_paras);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextViewWindow::syncEditorFromBuffer()
|
void TextViewWindow::syncEditorFromBuffer()
|
||||||
@ -215,3 +218,19 @@ void TextViewWindow::updateEditorFromConfig()
|
|||||||
m_editor->zoom(textEditorConfig.getZoomDelta());
|
m_editor->zoom(textEditorConfig.getZoomDelta());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextViewWindow::openTwice(const QSharedPointer<FileOpenParameters> &p_paras)
|
||||||
|
{
|
||||||
|
handleFileOpenParameters(p_paras);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextViewWindow::handleFileOpenParameters(const QSharedPointer<FileOpenParameters> &p_paras)
|
||||||
|
{
|
||||||
|
if (!p_paras) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_paras->m_lineNumber > -1) {
|
||||||
|
m_editor->scrollToLine(p_paras->m_lineNumber, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,6 +25,8 @@ namespace vnotex
|
|||||||
|
|
||||||
void setMode(ViewWindowMode p_mode) Q_DECL_OVERRIDE;
|
void setMode(ViewWindowMode p_mode) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void openTwice(const QSharedPointer<FileOpenParameters> &p_paras) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ namespace vnotex
|
|||||||
|
|
||||||
void updateEditorFromConfig();
|
void updateEditorFromConfig();
|
||||||
|
|
||||||
|
void handleFileOpenParameters(const QSharedPointer<FileOpenParameters> &p_paras);
|
||||||
|
|
||||||
static QSharedPointer<vte::TextEditorConfig> createTextEditorConfig(const TextEditorConfig &p_config);
|
static QSharedPointer<vte::TextEditorConfig> createTextEditorConfig(const TextEditorConfig &p_config);
|
||||||
|
|
||||||
// Managed by QObject.
|
// Managed by QObject.
|
||||||
|
@ -167,6 +167,8 @@ void ViewArea::openBuffer(Buffer *p_buffer, const QSharedPointer<FileOpenParamet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedWin->openTwice(p_paras);
|
||||||
|
|
||||||
setCurrentViewWindow(selectedWin);
|
setCurrentViewWindow(selectedWin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@ namespace vnotex
|
|||||||
|
|
||||||
void detachFromBuffer(bool p_quiet = false);
|
void detachFromBuffer(bool p_quiet = false);
|
||||||
|
|
||||||
|
// User request to open the buffer attached to this ViewWindow again.
|
||||||
|
virtual void openTwice(const QSharedPointer<FileOpenParameters> &p_paras) = 0;
|
||||||
|
|
||||||
virtual const QIcon &getIcon() const;
|
virtual const QIcon &getIcon() const;
|
||||||
|
|
||||||
virtual QString getName() const;
|
virtual QString getName() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user