Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
07118947
Commit
07118947
authored
Mar 20, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Mar 21, 2021
Browse files
Reintroduce position signal for location saving
Signed-off-by:
Waqar Ahmed
<
waqar.17a@gmail.com
>
parent
5a94d233
Changes
5
Hide whitespace changes
Inline
Side-by-side
kate/katepluginmanager.cpp
View file @
07118947
...
...
@@ -238,6 +238,15 @@ void KatePluginManager::enablePluginGUI(KatePluginInfo *item, KateMainWindow *wi
if
(
createdView
->
metaObject
()
->
indexOfSignal
(
"message(QVariantMap)"
)
!=
-
1
)
{
connect
(
createdView
,
SIGNAL
(
message
(
const
QVariantMap
&
)),
win
->
outputView
(),
SLOT
(
slotMessage
(
const
QVariantMap
&
)),
Qt
::
UniqueConnection
);
}
// ensure location tracking is connected for view
if
(
createdView
->
metaObject
()
->
indexOfSignal
(
"posChanged(QUrl,KTextEditor::Cursor)"
)
!=
-
1
)
{
connect
(
createdView
,
SIGNAL
(
posChanged
(
QUrl
,
KTextEditor
::
Cursor
)),
win
->
viewManager
(),
SLOT
(
savePosition
(
const
QUrl
&
,
KTextEditor
::
Cursor
)),
Qt
::
UniqueConnection
);
}
}
}
...
...
kate/kateviewmanager.cpp
View file @
07118947
...
...
@@ -322,6 +322,13 @@ void KateViewManager::openUrl(const QUrl &url)
openUrl
(
url
,
QString
());
}
void
KateViewManager
::
savePosition
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
pos
)
{
if
(
KateViewSpace
*
avs
=
activeViewSpace
())
{
avs
->
addJump
(
url
,
pos
,
/* calledExternally: */
true
);
}
}
KateMainWindow
*
KateViewManager
::
mainWindow
()
{
return
m_mainWindow
;
...
...
kate/kateviewmanager.h
View file @
07118947
...
...
@@ -67,6 +67,7 @@ public:
public
Q_SLOTS
:
void
openUrl
(
const
QUrl
&
url
);
void
savePosition
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
pos
);
public:
void
closeView
(
KTextEditor
::
View
*
view
);
...
...
kate/kateviewspace.cpp
View file @
07118947
...
...
@@ -474,8 +474,13 @@ void KateViewSpace::focusNextTab()
}
}
void
KateViewSpace
::
addJump
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
c
)
void
KateViewSpace
::
addJump
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
c
,
bool
calledExternally
)
{
// We don't care about invalid urls (Fixed Diff View / Untitled docs)
if
(
!
url
.
isValid
())
{
return
;
}
// we are in the middle of jumps somewhere?
if
(
!
m_locations
.
isEmpty
()
&&
currentLocation
+
1
<
m_locations
.
size
())
{
// erase all forward history
...
...
@@ -487,15 +492,30 @@ void KateViewSpace::addJump(const QUrl &url, KTextEditor::Cursor c)
m_locations
.
pop_back
();
}
// limit size to 100, remove first 20
if
(
m_locations
.
size
()
>=
100
)
{
m_locations
.
erase
(
m_locations
.
begin
(),
m_locations
.
begin
()
+
20
);
// Check if the location is at least "viewLineCount" away
if
(
!
calledExternally
&&
!
m_locations
.
isEmpty
()
&&
m_locations
.
back
().
url
==
url
)
{
int
line
=
c
.
line
();
int
lastLocLine
=
m_locations
.
back
().
cursor
.
line
();
auto
view
=
m_viewManager
->
activeView
();
int
viewLineCount
=
view
->
lastDisplayedLine
()
-
view
->
firstDisplayedLine
();
int
lowerBound
=
lastLocLine
-
viewLineCount
;
int
upperBound
=
lastLocLine
+
viewLineCount
;
if
(
lowerBound
<=
line
&&
line
<=
upperBound
)
{
return
;
}
}
// limit size to 50, remove first 10
if
(
m_locations
.
size
()
>=
50
)
{
m_locations
.
erase
(
m_locations
.
begin
(),
m_locations
.
begin
()
+
10
);
}
/
/
this is our new forward
/
**
this is our new forward
**/
m_locations
.
push_back
({
url
,
c
});
// set
to
last
// set
currentLocation as
last
currentLocation
=
m_locations
.
size
()
-
1
;
// disable forward button as we are at the end now
m_historyForward
->
setEnabled
(
false
);
...
...
kate/kateviewspace.h
View file @
07118947
...
...
@@ -91,6 +91,8 @@ public:
*/
void
focusNextTab
();
/** BEGIN Location History Stuff **/
/**
* go forward in location history
*/
...
...
@@ -111,6 +113,13 @@ public:
*/
bool
isHistoryForwardEnabled
()
const
;
/**
* Add a jump location for jumping back and forth between history
*/
void
addJump
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
,
bool
calledExternally
=
false
);
/** END Location History Stuff **/
public
Q_SLOTS
:
void
documentDestroyed
(
QObject
*
doc
);
void
updateDocumentName
(
KTextEditor
::
Document
*
doc
);
...
...
@@ -156,11 +165,6 @@ private:
*/
int
hiddenDocuments
()
const
;
/**
* Add a jump location for jumping back and forth between history
*/
void
addJump
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
);
private:
// Kate's view manager
KateViewManager
*
m_viewManager
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment