wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

inputbar.h (1614B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __INPUTBAR_H
      5 #define __INPUTBAR_H
      6 
      7 #include <set>
      8 #include <stack>
      9 #include <string>
     10 #include "wmi.h"
     11 
     12 #include "bar.h"
     13 
     14 class Action;
     15 class Monitor;
     16 class Prompt;
     17 class Theme;
     18 
     19 typedef set<string> Sstring;
     20 typedef stack<Sstring::iterator> SSstringIter;
     21 
     22 /**
     23  * Represents the input bar and input mode of WMI.
     24  */
     25 class InputBar: public Bar
     26 {
     27 
     28 public:
     29 
     30     InputBar(Monitor *monitor, Rectangle *rect);
     31 
     32     ~InputBar();
     33 
     34     virtual void illuminate();
     35 
     36     virtual void handleMotionNotify(XMotionEvent *event);
     37     virtual void handleButtonPress(XButtonEvent *event);
     38     virtual void handleButtonRelease(XButtonEvent *event);
     39 
     40     /** Handler for input key events. */
     41     void handleInput(XKeyEvent *event);
     42     void handlePressedReturn();
     43 
     44     void runKey(Prompt *prompt);
     45     void runArgument(Action *action);
     46 
     47 private:
     48 
     49     bool isArgument() const;
     50 
     51     string text(bool onExecEnter = false);
     52 
     53     void queryText(string text);
     54     void removeChar();
     55     void clearPrevPartitionsStack();
     56 
     57     void selectNextEntry();
     58     void selectPrevEntry();
     59 
     60     void escape();
     61 
     62     /** Provides argument processing. */
     63     Action *currAction_;
     64 
     65     Sstring names_;
     66 
     67     bool isArgument_;
     68     Sstring::iterator entryBegin_;
     69     Sstring::iterator entryEnd_;
     70     Sstring::iterator partitionBegin_;
     71     Sstring::iterator partitionEnd_;
     72     Sstring::iterator selected_;
     73     SSstringIter prevPartitions_;
     74     Prompt *prompt_;
     75     string text_;
     76     string args_;
     77     unsigned int promptCounter_;
     78 };
     79 
     80 #endif // __INPUTBAR_H