Commit bf2fcb95 authored by mit's avatar mit

type a number N to repeat N times the next command

parent 2dd4c172
......@@ -27,6 +27,7 @@ class Culendar:
self._prevehl = 0 # idem, previous one
# highlighted todo, if any, index starts at 1
self._todohl = 0 # focus on calendar on start
self._count = 0 # repetitions of the next command
# compute useful stuff
self.update()
......@@ -99,6 +100,15 @@ class Culendar:
def day_size(self):
return self._day_size
@property
def count(self):
return self._count
@count.setter
def count(self, count):
self._count = count
###############################################################################
# update functions
###############################################################################
......
......@@ -32,23 +32,25 @@ def main(stdscr):
if key == 'KEY_RESIZE':
cul.update()
# repeat action at least 1, or the entered count value
repetitions = max(1, cul.count)
# changing day or week or year
if key in conf.keys['prevday']:
cul.addday(-1)
cul.addday(-repetitions)
if key in conf.keys['nextday']:
cul.addday(+1)
cul.addday(+repetitions)
if key in conf.keys['nextweek']:
cul.addday(+7)
cul.addday(+7*repetitions)
if key in conf.keys['prevweek']:
cul.addday(-7)
cul.addday(-7*repetitions)
if key in conf.keys['nextmonth']:
cul.addmonth(+1)
cul.addmonth(+repetitions)
if key in conf.keys['prevmonth']:
cul.addmonth(-1)
cul.addmonth(-repetitions)
if key in conf.keys['nextyear']:
cul.addyear(+1)
cul.addyear(+repetitions)
if key in conf.keys['prevyear']:
cul.addyear(-1)
cul.addyear(-repetitions)
if key in conf.keys['today']:
cul.day = datetime.date.today()
cul.draw_week()
......@@ -62,11 +64,11 @@ def main(stdscr):
# change highlighted event of current day
if key in conf.keys['nextevent']:
cul.sameday()
cul.changehl(+1)
cul.changehl(+repetitions)
cul.draw_hl()
if key in conf.keys['prevevent']:
cul.sameday()
cul.changehl(-1)
cul.changehl(-repetitions)
cul.draw_hl()
# delete, edit, add (highlighted) event (if existing)
......@@ -118,6 +120,13 @@ def main(stdscr):
if key in conf.keys['export']:
cul.exportcal()
# define the buffer and the repetition of actions
try: # is the key an integer?
# type 1 then 2, get 12
cul.count = cul.count*10 + int(key)
except: # not a number, back to zero
cul.count = 0
# autosave on quit
if conf.autosave:
cul.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment