Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
bc278dfb
Commit
bc278dfb
authored
Jan 08, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'column-ui' of
https://github.com/bram85/topydo
into column-ui
parents
0d086fe7
73468221
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
topydo/ui/CommandLineWidget.py
topydo/ui/CommandLineWidget.py
+41
-0
No files found.
topydo/ui/CommandLineWidget.py
View file @
bc278dfb
...
@@ -18,6 +18,12 @@ import urwid
...
@@ -18,6 +18,12 @@ import urwid
class
CommandLineWidget
(
urwid
.
Edit
):
class
CommandLineWidget
(
urwid
.
Edit
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
history
=
None
self
.
history_pos
=
None
# temporary history storage for edits before cmd execution
self
.
history_tmp
=
None
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
urwid
.
register_signal
(
CommandLineWidget
,
[
'blur'
,
'execute_command'
])
urwid
.
register_signal
(
CommandLineWidget
,
[
'blur'
,
'execute_command'
])
...
@@ -30,12 +36,47 @@ class CommandLineWidget(urwid.Edit):
...
@@ -30,12 +36,47 @@ class CommandLineWidget(urwid.Edit):
def
_emit_command
(
self
):
def
_emit_command
(
self
):
urwid
.
emit_signal
(
self
,
'execute_command'
,
self
.
edit_text
)
urwid
.
emit_signal
(
self
,
'execute_command'
,
self
.
edit_text
)
self
.
_save_to_history
()
self
.
clear
()
self
.
clear
()
def
_save_to_history
(
self
):
if
len
(
self
.
edit_text
)
>
0
:
if
self
.
history
is
None
:
self
.
history
=
[]
self
.
history
.
append
(
self
.
edit_text
)
self
.
history_pos
=
len
(
self
.
history
)
self
.
history_tmp
=
self
.
history
[:]
# sync temporary storage with real history
self
.
history_tmp
.
append
(
''
)
def
_history_move
(
self
,
p_step
):
"""
Changes current value of the command-line to the value obtained from
history_tmp list with index calculated by addition of p_step to the
current position in the command history (history_pos attribute).
Also saves value of the command-line (before changing it) to history_tmp
for potential later access.
"""
if
self
.
history
is
not
None
:
# don't pollute real history - use temporary storage
self
.
history_tmp
[
self
.
history_pos
]
=
self
.
edit_text
self
.
history_pos
=
self
.
history_pos
+
p_step
self
.
set_edit_text
(
self
.
history_tmp
[
self
.
history_pos
])
def
_history_next
(
self
):
if
self
.
history_pos
!=
len
(
self
.
history
):
self
.
_history_move
(
1
)
def
_history_back
(
self
):
if
self
.
history_pos
!=
0
:
self
.
_history_move
(
-
1
)
def
keypress
(
self
,
p_size
,
p_key
):
def
keypress
(
self
,
p_size
,
p_key
):
dispatch
=
{
dispatch
=
{
'enter'
:
self
.
_emit_command
,
'enter'
:
self
.
_emit_command
,
'esc'
:
self
.
_blur
,
'esc'
:
self
.
_blur
,
'up'
:
self
.
_history_back
,
'down'
:
self
.
_history_next
}
}
try
:
try
:
...
...
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