Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
2d093440
Commit
2d093440
authored
Aug 22, 2016
by
Maxime Perrotin
Browse files
Search and replace with g is not applied to the whole model
%s,from,to,g -> g is global across all scenes
parent
9c2e5a6e
Changes
2
Show whitespace changes
Inline
Side-by-side
opengeode/Connectors.py
View file @
2d093440
...
...
@@ -83,6 +83,10 @@ class Connection(QGraphicsPathItem, object):
return
(
QPointF
(
endp
.
x
()
-
5
,
endp
.
y
()
-
5
),
QPointF
(
endp
.
x
()
+
5
,
endp
.
y
()
-
5
))
def
select
(
self
):
''' Select a connection - for future use? '''
return
def
angle_arrow
(
self
,
path
,
origin
=
'head'
):
''' Compute the two points of the arrow head with the right angle '''
if
origin
==
'tail'
:
...
...
opengeode/opengeode.py
View file @
2d093440
...
...
@@ -829,7 +829,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# invalid pattern
raise
StopIteration
if
res
:
yield
item
.
parentItem
()
yield
item
def
search
(
self
,
pattern
,
replace_with
=
None
):
...
...
@@ -847,16 +847,18 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
for
item
in
self
.
search_item
:
new_string
=
re
.
sub
(
pattern
,
replace_with
,
unicode
(
item
.
text
),
unicode
(
item
),
flags
=
re
.
IGNORECASE
)
undo_cmd
=
undoCommands
.
ReplaceText
(
item
.
text
,
unicode
(
item
.
text
),
new_string
)
item
,
unicode
(
item
),
new_string
)
self
.
undo_stack
.
push
(
undo_cmd
)
item
.
select
()
item
.
try_resize
()
item
.
parentItem
().
select
()
self
.
refresh
()
else
:
try
:
item
=
self
.
search_item
.
next
()
item
=
item
.
parentItem
()
item
.
select
()
self
.
highlight
(
item
)
item
.
ensureVisible
()
...
...
@@ -2170,13 +2172,21 @@ class OG_MainWindow(QtGui.QMainWindow, object):
'''
command
=
self
.
vi_bar
.
text
()
# Match vi-like search and replace pattern (e.g. :%s,a,b,g)
search
=
re
.
compile
(
r
':%s(.)(.*)\1(.*)\1(.)'
)
search
=
re
.
compile
(
r
':%s(.)(.*)\1(.*)\1(.)
?
'
)
try
:
_
,
pattern
,
new
,
_
=
search
.
match
(
command
).
groups
()
_
,
pattern
,
new
,
loc
=
search
.
match
(
command
).
groups
()
LOG
.
debug
(
'Replacing {this} with {that}'
.
format
(
this
=
pattern
,
that
=
new
))
if
loc
!=
'g'
:
# apply only to the current scene
self
.
view
.
scene
().
search
(
pattern
,
replace_with
=
new
)
except
AttributeError
:
else
:
# apply globally to the whole model
scene
=
self
.
view
.
top_scene
()
for
each
in
chain
([
scene
],
scene
.
all_nested_scenes
):
each
.
search
(
pattern
,
replace_with
=
new
)
except
AttributeError
as
err
:
print
'attribute error'
,
str
(
err
)
if
command
.
startswith
(
'/'
)
and
len
(
command
)
>
1
:
LOG
.
debug
(
'Searching for '
+
command
[
1
:])
self
.
view
.
scene
().
search
(
command
[
1
:])
...
...
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