Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maxime Buquet
poezio
Commits
534ba14d
Unverified
Commit
534ba14d
authored
Jul 21, 2018
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix /reorder
parent
784f2d28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
plugins/reorder.py
plugins/reorder.py
+11
-18
poezio/core/tabs.py
poezio/core/tabs.py
+4
-8
No files found.
plugins/reorder.py
View file @
534ba14d
...
...
@@ -80,18 +80,18 @@ TAB_TO_TEXT = {
tabs
.
GapTab
:
'empty'
}
def
parse_config
(
config
):
def
parse_config
(
tab_
config
):
result
=
{}
for
option
in
config
.
options
(
'reorder'
):
for
option
in
tab_
config
.
options
(
'reorder'
):
if
not
option
.
isdecimal
():
continue
pos
=
int
(
option
)
if
pos
in
result
or
pos
<=
0
:
return
return
None
typ
,
name
=
config
.
get
(
option
,
default
=
':'
).
split
(
':'
,
maxsplit
=
1
)
typ
,
name
=
tab_
config
.
get
(
option
,
default
=
':'
).
split
(
':'
,
maxsplit
=
1
)
if
typ
not
in
TEXT_TO_TAB
:
return
return
None
result
[
pos
]
=
(
TEXT_TO_TAB
[
typ
],
name
)
return
result
...
...
@@ -132,25 +132,22 @@ class Plugin(BasePlugin):
"""
/reorder
"""
self
.
core
.
go_to_roster
()
self
.
core
.
current_tab_nb
=
0
tabs_spec
=
parse_config
(
self
.
config
)
if
not
tabs_spec
:
return
self
.
api
.
information
(
'Invalid reorder config'
,
'Error'
)
old_tabs
=
self
.
core
.
tabs
[
1
:]
roster
=
self
.
core
.
tabs
[
0
]
old_tabs
=
self
.
core
.
tabs
.
get_tabs
()
roster
=
old_tabs
.
pop
(
0
)
create_gaps
=
config
.
get
(
'create_gaps'
)
new_tabs
=
[]
new_tabs
=
[
roster
]
last
=
0
for
pos
in
sorted
(
tabs_spec
):
if
create_gaps
and
pos
>
last
+
1
:
new_tabs
+=
[
tabs
.
GapTab
(
self
.
core
)
for
i
in
range
(
pos
-
last
)]
new_tabs
+=
[
tabs
.
GapTab
(
self
.
core
)
for
i
in
range
(
pos
-
last
-
1
)]
cls
,
name
=
tabs_spec
[
pos
]
tab
=
self
.
core
.
get_tab_by_name
(
name
,
typ
=
cls
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
name
,
cls
=
cls
)
if
tab
and
tab
in
old_tabs
:
new_tabs
.
append
(
tab
)
old_tabs
.
remove
(
tab
)
...
...
@@ -164,9 +161,5 @@ class Plugin(BasePlugin):
if
tab
:
new_tabs
.
append
(
tab
)
self
.
core
.
tabs
.
clear
()
self
.
core
.
tabs
.
append
(
roster
)
self
.
core
.
tabs
+=
new_tabs
self
.
core
.
tabs
.
replace_tabs
(
new_tabs
)
self
.
core
.
refresh_window
()
poezio/core/tabs.py
View file @
534ba14d
...
...
@@ -141,20 +141,16 @@ class Tabs:
self
.
_tab_names
[
tab
.
name
]
=
tab
self
.
_update_numbers
()
def
replace_tabs
(
self
,
new_tabs
:
List
[
tabs
.
Tab
]):
def
replace_tabs
(
self
,
new_tabs
:
List
[
tabs
.
Tab
])
->
bool
:
"""
Replace the current tab list with another, and
rebuild the mappings.
"""
if
self
.
_current_tab
not
in
new_tabs
:
return
False
self
.
_tabs
=
new_tabs
self
.
_rebuild
()
current_tab
=
self
.
current_tab
try
:
idx
=
self
.
_tabs
.
index
(
current_tab
)
self
.
_current_index
=
idx
except
ValueError
:
self
.
_current_index
=
0
self
.
_current_tab
=
self
.
_tabs
[
0
]
return
True
def
_inc_cursor
(
self
):
self
.
_current_index
=
(
self
.
_current_index
+
1
)
%
len
(
self
.
_tabs
)
...
...
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