Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
cb1fb7e6
Commit
cb1fb7e6
authored
Mar 25, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
symmetric selection handling
parent
188fbe73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
src/gui/value/text.cpp
src/gui/value/text.cpp
+12
-4
No files found.
src/gui/value/text.cpp
View file @
cb1fb7e6
...
...
@@ -563,6 +563,13 @@ void TextValueEditor::moveSelectionNoRedraw(IndexType t, size_t new_end, bool al
fixSelection
(
t
,
dir
);
}
// direction of a with respect to b
Movement
direction_of
(
size_t
a
,
size_t
b
)
{
if
(
a
<
b
)
return
MOVE_LEFT_OPT
;
if
(
a
>
b
)
return
MOVE_RIGHT_OPT
;
else
return
MOVE_MID
;
}
void
TextValueEditor
::
fixSelection
(
IndexType
t
,
Movement
dir
)
{
const
String
&
val
=
value
().
value
();
// Which type takes precedent?
...
...
@@ -571,8 +578,9 @@ void TextValueEditor::fixSelection(IndexType t, Movement dir) {
selection_end
=
index_to_cursor
(
value
().
value
(),
selection_end_i
,
dir
);
}
// make sure the selection is at a valid position inside the text
selection_start_i
=
cursor_to_index
(
val
,
selection_start
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_RIGHT_OPT
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT_OPT
);
// prepare to move 'inward' (i.e. from start in the direction of end and vice versa)
selection_start_i
=
cursor_to_index
(
val
,
selection_start
,
direction_of
(
selection_end
,
selection_start
));
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
direction_of
(
selection_start
,
selection_end
));
// start and end must be on the same side of separators
size_t
seppos
=
val
.
find
(
_
(
"<sep"
));
while
(
seppos
!=
String
::
npos
)
{
...
...
@@ -580,11 +588,11 @@ void TextValueEditor::fixSelection(IndexType t, Movement dir) {
if
(
selection_start_i
<=
seppos
&&
selection_end_i
>
seppos
)
{
// not on same side, move selection end before sep
selection_end
=
index_to_cursor
(
val
,
seppos
,
dir
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT_OPT
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
direction_of
(
selection_start
,
selection_end
)
);
}
else
if
(
selection_start_i
>=
sepend
&&
selection_end_i
<
sepend
)
{
// not on same side, move selection end after sep
selection_end
=
index_to_cursor
(
val
,
sepend
,
dir
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
selection_start
==
selection_end
?
MOVE_MID
:
MOVE_LEFT_OPT
);
selection_end_i
=
cursor_to_index
(
val
,
selection_end
,
direction_of
(
selection_start
,
selection_end
)
);
}
// find next separator
seppos
=
val
.
find
(
_
(
"<sep"
),
seppos
+
1
);
...
...
Write
Preview
Markdown
is supported
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