Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Peter Shkenev
gajim
Commits
324fbeae
Commit
324fbeae
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
command autocompletion (patch from aldafu)
parent
f7732b30
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/groupchat_window.py
+27
-2
27 additions, 2 deletions
src/groupchat_window.py
with
27 additions
and
2 deletions
src/groupchat_window.py
+
27
−
2
View file @
324fbeae
...
...
@@ -41,13 +41,15 @@ class GroupchatWindow(chat.Chat):
"""
Class for Groupchat window
"""
def
__init__
(
self
,
room_jid
,
nick
,
plugin
,
account
):
chat
.
Chat
.
__init__
(
self
,
plugin
,
account
,
'
groupchat_window
'
)
self
.
muc_cmds
=
[
'
chat
'
,
'
clear
'
,
'
me
'
,
'
msg
'
,
'
nick
'
]
# alphanum sorted
self
.
nicks
=
{}
# our nick for each groupchat we are in
self
.
list_treeview
=
{}
self
.
subjects
=
{}
self
.
name_labels
=
{}
self
.
subject_tooltip
=
{}
self
.
room_creation
=
{}
self
.
nick_hits
=
{}
self
.
nick_hits
=
{}
# possible candidates for nick completion
self
.
cmd_hits
=
{}
# possible candidates for command completion
self
.
last_key_tabs
=
{}
self
.
hpaneds
=
{}
# used for auto positioning
self
.
hpaned_position
=
gajim
.
config
.
get
(
'
gc-hpaned-position
'
)
...
...
@@ -384,13 +386,34 @@ def on_message_textview_key_press_event(self, widget, event):
if
event
.
state
&
gtk
.
gdk
.
CONTROL_MASK
:
# CTRL + TAB
self
.
notebook
.
emit
(
'
key_press_event
'
,
event
)
else
:
list_nick
=
self
.
get_nick_list
(
room_jid
)
cursor_position
=
message_buffer
.
get_insert
()
end_iter
=
message_buffer
.
get_iter_at_mark
(
cursor_position
)
text
=
message_buffer
.
get_text
(
start_iter
,
end_iter
,
False
)
if
not
text
or
text
.
endswith
(
'
'
):
if
not
self
.
last_key_tabs
[
room_jid
]:
# if we are nick cycling, last char will always be space
return
False
# command completion
if
text
.
startswith
(
'
/
'
)
and
len
(
text
.
split
())
==
1
:
if
len
(
text
)
==
1
:
# user wants to cycle all commands
self
.
cmd_hits
[
room_jid
]
=
self
.
muc_cmds
else
:
# cycle possible commands depending on what the user typed
if
self
.
last_key_tabs
[
room_jid
]
and
\
self
.
cmd_hits
[
room_jid
][
0
].
startswith
(
text
.
lstrip
(
'
/
'
)):
self
.
cmd_hits
[
room_jid
].
append
(
self
.
cmd_hits
[
room_jid
][
0
])
self
.
cmd_hits
[
room_jid
].
pop
(
0
)
else
:
# find possible commands
self
.
cmd_hits
[
room_jid
]
=
[]
for
cmd
in
self
.
muc_cmds
:
if
cmd
.
startswith
(
text
.
lstrip
(
'
/
'
)):
self
.
cmd_hits
[
room_jid
].
append
(
cmd
)
message_buffer
.
delete
(
start_iter
,
end_iter
)
message_buffer
.
insert_at_cursor
(
'
/
'
+
self
.
cmd_hits
[
room_jid
][
0
])
self
.
last_key_tabs
[
room_jid
]
=
True
return
True
# nick completion
splitted_text
=
text
.
split
()
# check if tab is pressed with empty message
if
len
(
splitted_text
):
# if there are any words
...
...
@@ -404,6 +427,7 @@ def on_message_textview_key_press_event(self, widget, event):
self
.
nick_hits
[
room_jid
].
pop
(
0
)
else
:
self
.
nick_hits
[
room_jid
]
=
[]
# clear the hit list
list_nick
=
self
.
get_nick_list
(
room_jid
)
for
nick
in
list_nick
:
if
nick
.
lower
().
startswith
(
begin
.
lower
()):
# the word is the begining of a nick
self
.
nick_hits
[
room_jid
].
append
(
nick
)
...
...
@@ -723,6 +747,7 @@ def new_room(self, room_jid, nick):
self
.
subjects
[
room_jid
]
=
''
self
.
room_creation
[
room_jid
]
=
time
.
time
()
self
.
nick_hits
[
room_jid
]
=
[]
self
.
cmd_hits
[
room_jid
]
=
[]
self
.
last_key_tabs
[
room_jid
]
=
False
self
.
hpaneds
[
room_jid
]
=
self
.
xmls
[
room_jid
].
get_widget
(
'
hpaned
'
)
self
.
list_treeview
[
room_jid
]
=
self
.
xmls
[
room_jid
].
get_widget
(
...
...
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