Add Readline history for editing task
authorJoey Schulze <joey@infodrom.org>
Thu, 1 Oct 2015 19:11:49 +0000 (19:11 +0000)
committerJoey Schulze <joey@infodrom.org>
Thu, 1 Oct 2015 19:11:49 +0000 (19:11 +0000)
src/InfoCon/stempel/stempel

index be9b66c..b3abec9 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 
-#  Time Tracker
-#  Copyright (c) 2007,8,13,14  Martin Schulze <joey@infodrom.org>
+#  InfoCon Time Tracker
+#  Copyright (c) 2007,8,13,14,15  Martin Schulze <joey@infodrom.org>
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -299,6 +299,18 @@ sub alter_task
 
     my $term = new Term::ReadLine '';
 
+    my $sql = q{SELECT customer,task FROM stempel WHERE stop IS NULL};
+    my $sth = $dbh->prepare($sql);
+    $sth->execute;
+    my $row = $sth->fetchrow_hashref;
+
+    my $tasks = tasklist $row->{'customer'};
+    $term->addhistory($_) foreach (@$tasks);
+
+    my $attribs = $term->Attribs;
+    $attribs->{completion_word} = $tasks;
+    $term->{completion_function} = sub {return complete_customer $row->{'customer'}, @_};
+
     my $task = $term->readline ('Aufgabe: ');
 
     if (length($task) > 0) {