Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
030525fe
Commit
030525fe
authored
14 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
better fix for BZDNG-238, this time including the backspace key
parent
1d2d0424
No related branches found
Tags
v0.2.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/gui/src/python_shell/python_shell_widget.cc
+14
-5
14 additions, 5 deletions
modules/gui/src/python_shell/python_shell_widget.cc
with
14 additions
and
5 deletions
modules/gui/src/python_shell/python_shell_widget.cc
+
14
−
5
View file @
030525fe
...
@@ -474,6 +474,7 @@ void PythonShellWidget::OnExecuteStateEntered()
...
@@ -474,6 +474,7 @@ void PythonShellWidget::OnExecuteStateEntered()
set_block_type_
(
block_edit_start_
,
textCursor
().
block
(),
BLOCKTYPE_CODE
);
set_block_type_
(
block_edit_start_
,
textCursor
().
block
(),
BLOCKTYPE_CODE
);
insertPlainText
(
QString
(
QChar
::
ParagraphSeparator
));
insertPlainText
(
QString
(
QChar
::
ParagraphSeparator
));
QString
command
=
GetCommand
();
QString
command
=
GetCommand
();
QString
command_trimmed
=
command
.
trimmed
();
QString
command_trimmed
=
command
.
trimmed
();
if
(
command_trimmed
.
size
()
>
0
)
{
if
(
command_trimmed
.
size
()
>
0
)
{
unsigned
int
id
=
PythonInterpreter
::
Instance
().
RunCommand
(
command
);
unsigned
int
id
=
PythonInterpreter
::
Instance
().
RunCommand
(
command
);
...
@@ -482,7 +483,6 @@ void PythonShellWidget::OnExecuteStateEntered()
...
@@ -482,7 +483,6 @@ void PythonShellWidget::OnExecuteStateEntered()
insertPlainText
(
QString
(
QChar
::
ParagraphSeparator
));
insertPlainText
(
QString
(
QChar
::
ParagraphSeparator
));
}
}
block_edit_start_
=
textCursor
().
block
();
block_edit_start_
=
textCursor
().
block
();
std
::
cout
<<
block_edit_start_
.
isValid
()
<<
std
::
endl
;
}
}
...
@@ -739,22 +739,29 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
...
@@ -739,22 +739,29 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
{
{
// BZDNG-238
// BZDNG-238
// Letting Qt do the handling of the backspace key leads to a crash when
// Letting Qt do the handling of the backspace key leads to a crash when
// multiline block mode and doing the following:
//
editing a
multiline block mode and doing the following:
//
//
// (a) Hit Ctrl+A
// (a) Hit Ctrl+A
// (b) Hit Backspace
// (b) Hit Backspace
|Delete
// (c) Hit Return
// (c) Hit Return
//
//
// If we emulate the deletion of the text manually all is fine.
// If we emulate the deletion of the text manually all is fine.
if
(
event
->
key
()
==
Qt
::
Key_Backspace
)
{
if
(
event
->
key
()
==
Qt
::
Key_Backspace
||
event
->
key
()
==
Qt
::
Key_Delete
)
{
QTextCursor
cursor
=
this
->
textCursor
();
QTextCursor
cursor
=
this
->
textCursor
();
if
(
cursor
.
hasSelection
())
{
if
(
cursor
.
hasSelection
())
{
cursor
.
removeSelectedText
();
cursor
.
removeSelectedText
();
}
else
{
}
else
{
if
(
cursor
.
position
()
>
this
->
GetEditStartBlock
().
position
())
{
if
(
cursor
.
position
()
>
this
->
GetEditStartBlock
().
position
())
{
cursor
.
deletePreviousChar
();
if
(
event
->
key
()
==
Qt
::
Key_Backspace
)
{
cursor
.
deletePreviousChar
();
}
else
{
cursor
.
deleteChar
();
}
}
}
}
}
QTextCursor
tc
=
this
->
textCursor
();
tc
.
setPosition
(
block_edit_start_
.
position
());
block_edit_start_
=
tc
.
block
();
event
->
accept
();
event
->
accept
();
return
;
return
;
}
}
...
@@ -767,9 +774,11 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
...
@@ -767,9 +774,11 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
}
}
}
}
if
(
this
->
handle_custom_commands_
(
event
)){
if
(
this
->
handle_custom_commands_
(
event
)){
event
->
accept
();
return
;
return
;
}
}
if
(
this
->
handle_completion_
(
event
)){
if
(
this
->
handle_completion_
(
event
)){
event
->
accept
();
return
;
return
;
}
}
QPlainTextEdit
::
keyPressEvent
(
event
);
QPlainTextEdit
::
keyPressEvent
(
event
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment