Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
a7fe7c6f
Commit
a7fe7c6f
authored
Dec 1, 2022
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add commenting shortcut to editor
+ via edit menu or CTRL+B
parent
77c7bc25
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/editor.py
+53
-33
53 additions, 33 deletions
Ccs/editor.py
with
53 additions
and
33 deletions
Ccs/editor.py
+
53
−
33
View file @
a7fe7c6f
...
@@ -52,6 +52,7 @@ UI_INFO = """
...
@@ -52,6 +52,7 @@ UI_INFO = """
<menuitem action=
'
EditPaste
'
/>
<menuitem action=
'
EditPaste
'
/>
<separator />
<separator />
<menuitem action=
'
EditFind
'
/>
<menuitem action=
'
EditFind
'
/>
<menuitem action=
'
EditComment
'
/>
<separator />
<separator />
<menuitem action=
'
EditPreferences
'
/>
<menuitem action=
'
EditPreferences
'
/>
</menu>
</menu>
...
@@ -633,7 +634,11 @@ class CcsEditor(Gtk.Window):
...
@@ -633,7 +634,11 @@ class CcsEditor(Gtk.Window):
action
.
connect
(
"
activate
"
,
self
.
on_search_clicked
)
action
.
connect
(
"
activate
"
,
self
.
on_search_clicked
)
action_group
.
add_action_with_accel
(
action
,
"
<control>F
"
)
action_group
.
add_action_with_accel
(
action
,
"
<control>F
"
)
action
=
Gtk
.
Action
(
name
=
"
EditPreferences
"
,
label
=
"
_Preferences
"
,
tooltip
=
None
,
stock_id
=
Gtk
.
STOCK_PREFERENCES
)
action
=
Gtk
.
Action
(
name
=
"
EditComment
"
,
label
=
"
Comment Line(s)
"
,
tooltip
=
None
)
action
.
connect
(
"
activate
"
,
self
.
_on_comment_lines
)
action_group
.
add_action_with_accel
(
action
,
"
<control>B
"
)
action
=
Gtk
.
Action
(
name
=
"
EditPreferences
"
,
label
=
"
Preferences
"
,
tooltip
=
None
,
stock_id
=
Gtk
.
STOCK_PREFERENCES
)
action
.
connect
(
"
activate
"
,
cfl
.
start_config_editor
)
action
.
connect
(
"
activate
"
,
cfl
.
start_config_editor
)
action_group
.
add_action
(
action
)
action_group
.
add_action
(
action
)
...
@@ -737,38 +742,53 @@ class CcsEditor(Gtk.Window):
...
@@ -737,38 +742,53 @@ class CcsEditor(Gtk.Window):
def
_on_menu_file_new
(
self
,
widget
=
None
,
filename
=
None
):
def
_on_menu_file_new
(
self
,
widget
=
None
,
filename
=
None
):
self
.
notebook_open_tab
()
self
.
notebook_open_tab
()
# def _on_select_pool_config(self, action):
def
_on_comment_lines
(
self
,
widget
=
None
):
# print('TODO')
view
=
self
.
_get_active_view
()
#
textbuffer
=
view
.
get_buffer
()
# def _on_edit_pool_config(self, action):
# print('TODO')
hs
=
textbuffer
.
get_has_selection
()
#
# def _on_create_pool_config(self, action):
if
hs
:
# cfg_dialog = config_dialog.CreateConfig(self)
x
,
y
=
textbuffer
.
get_selection_bounds
()
# response = cfg_dialog.run()
#
# remember selected part for re-selection at the end
# config = cfg_dialog.get_config()
ix
=
x
.
get_offset
()
# cfg_dialog.destroy()
iyl
,
iyo
=
y
.
get_line
(),
y
.
get_line_offset
()
#
# if response == Gtk.ResponseType.CANCEL:
x
.
set_line_offset
(
0
)
# return
tt
=
x
.
get_text
(
y
)
#
lnlist
=
tt
.
split
(
'
\n
'
)
# dialog = Gtk.FileChooserDialog(title="Save file as", parent=None,
if
all
([
ln
.
startswith
(
'
#
'
)
for
ln
in
lnlist
]):
# action=Gtk.FileChooserAction.SAVE)
newbuf
=
[]
# dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
for
ln
in
lnlist
:
# Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
newbuf
.
append
(
ln
[
1
:])
#
tr
=
'
\n
'
.
join
(
newbuf
)
# dialog.set_transient_for(self)
ix
-=
1
#
iyo
-=
1
# response = dialog.run()
else
:
#
tr
=
'
#
'
+
tt
.
replace
(
'
\n
'
,
'
\n
#
'
)
# if response == Gtk.ResponseType.OK:
ix
+=
1
# filename = dialog.get_filename()
iyo
+=
1
# with open(filename, 'w') as fdesc:
# config.write(fdesc)
else
:
# fdesc.close()
x
=
textbuffer
.
get_iter_at_mark
(
textbuffer
.
get_insert
())
#
x
.
set_line_offset
(
0
)
# dialog.destroy()
y
=
x
.
copy
()
y
.
forward_to_line_end
()
tt
=
x
.
get_text
(
y
)
if
tt
.
startswith
(
'
#
'
):
tr
=
tt
[
1
:]
else
:
tr
=
'
#
'
+
tt
textbuffer
.
delete
(
x
,
y
)
textbuffer
.
insert
(
x
,
tr
,
len
(
tr
))
if
hs
:
x
=
textbuffer
.
get_iter_at_offset
(
ix
)
y
=
textbuffer
.
get_iter_at_line_offset
(
iyl
,
iyo
)
textbuffer
.
select_range
(
x
,
y
)
def
_on_start_poolviewer
(
self
,
action
):
def
_on_start_poolviewer
(
self
,
action
):
cfl
.
start_pv
()
cfl
.
start_pv
()
...
...
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
sign in
to comment