OOStuBS - Technische Informatik II (TI-II)  2.4
task5.cc
gehe zur Dokumentation dieser Datei
1 #include "user/task5.h"
2 
3 #include "object/keyboard.h"
4 #include "object/kout.h"
5 #include "object/lock.h"
6 #include "locking/scopedLock.h"
7 
9 }
10 
12  jobs.registerJob(counter1, "Counter-1");
13  jobs.registerJob(counter2, "Counter-2");
14  jobs.registerJob(rotCursor, "Rotating-Cursor");
15 
16  while(true){
17  unsigned short x,y;
18  lock.lock();
19  kout.clear();
20  kout.setpos(31,1);
21  kout << "OOStuBs - Task 5" << endl;
23  kout << "oostubs:$ ";
24  kout.flush();
25  kout.getpos(x,y);
26  cmdLine.clear();
27  lock.unlock();
28  while(!cmdLine.finished()){
29  Key k = keyboard.getkey();
30 
31  ScopedLock scopedLock(lock);
32  if(k.scancode() == Key::scan::del){
33  kout.setpos(x-1,y);
34  kout << " ";
35  kout.flush();
36  kout.setpos(x-1,y);
37  cmdLine.erase();
38  }
39  kout.setpos(x,y);
40  kout << k.ascii();
41  kout.flush();
42  kout.getpos(x,y);
43  cmdLine.feed(k.ascii());
44  }
45  const char* arg;
46  switch(cmdLine.result(&arg)){
47  case(Parser::start): jobs.start(arg);
48  break;
49  case(Parser::kill): jobs.stop(arg);
50  break;
51  case(Parser::list): {
52  ScopedLock scopedLock(lock);
53  kout << "jobs: " << endl << jobs;
54  }
55  break;
56  case(Parser::help):
57  case(Parser::unknown): {
58  ScopedLock scopedLock(lock);
59  kout << "commands: " << endl << cmdLine;
60  }
61  break;
62  };
63  keyboard.getkey();
64  }
65 }