Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
7c887960
Commit
7c887960
authored
Feb 01, 2010
by
Roberto Raggi
Browse files
Changed BaseTextEditor::Link to use a pair of offsets (begin, end) instead of position and length.
Done with: Thorbjorn.
parent
460c47f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
7c887960
...
...
@@ -1305,14 +1305,17 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
QTextBlock
block
;
const
SimpleToken
tk
=
tokenUnderCursor
(
tc
,
&
block
);
const
int
beginOfToken
=
block
.
position
()
+
tk
.
begin
();
const
int
endOfToken
=
block
.
position
()
+
tk
.
end
();
// Handle include directives
if
(
tk
.
is
(
T_STRING_LITERAL
)
||
tk
.
is
(
T_ANGLE_STRING_LITERAL
))
{
const
unsigned
lineno
=
cursor
.
blockNumber
()
+
1
;
foreach
(
const
Document
::
Include
&
incl
,
doc
->
includes
())
{
if
(
incl
.
line
()
==
lineno
&&
incl
.
resolved
())
{
link
.
fileName
=
incl
.
fileName
();
link
.
pos
=
cursor
.
block
().
position
()
+
tk
.
position
()
+
1
;
link
.
l
en
gth
=
tk
.
length
()
-
2
;
link
.
begin
=
beginOfToken
+
1
;
link
.
en
d
=
endOfToken
-
1
;
return
link
;
}
}
...
...
@@ -1326,12 +1329,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
if
(
!
lastSymbol
)
return
link
;
const
int
nameStart
=
tk
.
position
();
const
int
nameLength
=
tk
.
length
();
const
int
endOfName
=
block
.
position
()
+
nameStart
+
nameLength
;
const
QString
name
=
block
.
text
().
mid
(
nameStart
,
nameLength
);
tc
.
setPosition
(
endOfName
);
tc
.
setPosition
(
endOfToken
);
// Evaluate the type of the expression under the cursor
ExpressionUnderCursor
expressionUnderCursor
;
...
...
@@ -1384,8 +1382,8 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
def
=
findDefinition
(
symbol
);
link
=
linkToSymbol
(
def
?
def
:
symbol
);
link
.
pos
=
block
.
position
()
+
nameStart
;
link
.
l
en
gth
=
nameLength
;
link
.
begin
=
beginOfToken
;
link
.
en
d
=
endOfToken
;
return
link
;
// This would jump to the type of a name
...
...
@@ -1400,13 +1398,13 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
}
}
else
{
// Handle macro uses
const
Document
::
MacroUse
*
use
=
doc
->
findMacroUseAt
(
endOf
Name
-
1
);
const
Document
::
MacroUse
*
use
=
doc
->
findMacroUseAt
(
endOf
Token
-
1
);
if
(
use
)
{
const
Macro
&
macro
=
use
->
macro
();
link
.
fileName
=
macro
.
fileName
();
link
.
line
=
macro
.
line
();
link
.
pos
=
use
->
begin
();
link
.
l
en
gth
=
use
->
end
()
-
use
->
begin
()
;
link
.
begin
=
use
->
begin
();
link
.
en
d
=
use
->
end
();
return
link
;
}
}
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
7c887960
...
...
@@ -4144,8 +4144,8 @@ void BaseTextEditor::showLink(const Link &link)
QTextEdit
::
ExtraSelection
sel
;
sel
.
cursor
=
textCursor
();
sel
.
cursor
.
setPosition
(
link
.
pos
);
sel
.
cursor
.
setPosition
(
link
.
pos
+
link
.
length
,
QTextCursor
::
KeepAnchor
);
sel
.
cursor
.
setPosition
(
link
.
begin
);
sel
.
cursor
.
setPosition
(
link
.
end
,
QTextCursor
::
KeepAnchor
);
sel
.
format
=
d
->
m_linkFormat
;
sel
.
format
.
setFontUnderline
(
true
);
setExtraSelections
(
OtherSelection
,
QList
<
QTextEdit
::
ExtraSelection
>
()
<<
sel
);
...
...
src/plugins/texteditor/basetexteditor.h
View file @
7c887960
...
...
@@ -567,21 +567,21 @@ protected:
Link
(
const
QString
&
fileName
=
QString
(),
int
line
=
0
,
int
column
=
0
)
:
pos
(
-
1
)
,
l
en
gth
(
-
1
)
:
begin
(
-
1
)
,
en
d
(
-
1
)
,
fileName
(
fileName
)
,
line
(
line
)
,
column
(
column
)
{}
bool
isValid
()
const
{
return
!
(
pos
==
-
1
||
length
==
-
1
)
;
}
{
return
begin
!=
end
;
}
bool
operator
==
(
const
Link
&
other
)
const
{
return
pos
==
other
.
pos
&&
l
en
gth
==
other
.
l
en
gth
;
}
{
return
begin
==
other
.
begin
&&
en
d
==
other
.
en
d
;
}
int
pos
;
// Link position
int
l
en
gth
;
// Link
l
en
gth
int
begin
;
// Link position
int
en
d
;
// Link en
d position
QString
fileName
;
// Target file
int
line
;
// Target line
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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