| src/Completer.cc | |
| 11 | @@ -11,10 +11,12 @@ |
| 11 | #endif // HAVE_CONFIG_H |
| 12 | |
| 13 | #include <cstdlib> |
| 14 | #include <algorithm> |
| 15 | #include <iostream> |
| 16 | #include <list> |
| 17 | #include <vector> |
| 18 | #include <string> |
| 19 | #include <set> |
| 20 | |
| 21 | extern "C" { |
| 22 | #include <sys/types.h> |
| ... | |
| 27 | @@ -25,7 +27,12 @@ |
| 27 | #include "Completer.hh" |
| 28 | #include "Config.hh" |
| 29 | #include "Util.hh" |
| 30 | #ifdef MENUS |
| 31 | #include "PWinObj.hh" |
| 32 | #include "MenuHandler.hh" |
| 33 | #endif // MENUS |
| 34 | |
| 35 | using std::copy; |
| 36 | using std::cerr; |
| 37 | using std::wcerr; |
| 38 | using std::endl; |
| ... | |
| 40 | @@ -33,21 +40,34 @@ |
| 40 | using std::vector; |
| 41 | using std::string; |
| 42 | using std::wstring; |
| 43 | using std::pair; |
| 44 | using std::set; |
| 45 | |
| 46 | ActionCompleterMethod::StateMatch ActionCompleterMethod::STATE_MATCHES[] = { |
| 47 | StateMatch(ActionCompleterMethod::STATE_STATE, L"set"), |
| 48 | StateMatch(ActionCompleterMethod::STATE_STATE, L"unset"), |
| 49 | StateMatch(ActionCompleterMethod::STATE_STATE, L"toggle"), |
| 50 | StateMatch(ActionCompleterMethod::STATE_MENU, L"showmenu") |
| 51 | }; |
| 52 | |
| 53 | /** |
| 47 | * Complete str with available path elements. |
| 55 | * Find matches for word in completions_list and add to completions. |
| 56 | */ |
| 57 | unsigned int |
| 51 | PathCompleterMethod::complete(const wstring &str, const wstring &word, complete_list &completions) |
| 59 | CompleterMethod::complete_word(completions_list &completions_list, |
| 60 | complete_list &completions, |
| 61 | const std::wstring &word) |
| 62 | { |
| 56 | unsigned int completed = 0; |
| 64 | unsigned int completed = 0, equality = -1; |
| 65 | |
| 59 | list<wstring>::iterator it(_path_list.begin()); |
| 60 | for (; it != _path_list.end(); ++it) { |
| 61 | // FIXME: Break when comparsion is > 0 |
| 62 | if (it->size() >= word.size() |
| 63 | && it->compare(0, word.size(), word, 0, word.size()) == 0) { |
| 64 | completions.push_back(*it); |
| 72 | completions_it it(completions_list.begin()); |
| 73 | for (; it != completions_list.end(); ++it) { |
| 74 | if (it->first.size() < word.size()) { |
| 75 | continue; |
| 76 | } |
| 77 | equality = it->first.compare(0, word.size(), word, 0, word.size()); |
| 78 | if (equality == 0) { |
| 79 | completions.push_back(it->second); |
| 80 | completed++; |
| 81 | } |
| 82 | } |
| ... | |
| 76 | @@ -56,6 +76,17 @@ |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Complete str with available path elements. |
| 80 | */ |
| 81 | unsigned int |
| 82 | PathCompleterMethod::complete(CompletionState &completion_state) |
| 83 | { |
| 84 | return complete_word(_path_list, |
| 85 | completion_state.completions, |
| 86 | completion_state.word); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Refresh available completions. |
| 91 | */ |
| 92 | void |
| ... | |
| 94 | @@ -63,33 +94,111 @@ |
| 94 | { |
| 95 | // Clear out previous data |
| 96 | _path_list.clear(); |
| 97 | _path_name_set.clear(); |
| 98 | |
| 99 | set<pair<wstring, wstring> > name_set; |
| 100 | vector<string> path_parts; |
| 101 | Util::splitString(getenv("PATH") ? getenv("PATH") : "", path_parts, ":"); |
| 102 | |
| 103 | vector<string>::iterator it(path_parts.begin()); |
| 104 | for (; it != path_parts.end(); ++it) { |
| 105 | DIR *dh = opendir(it->c_str()); |
| 75 | if (! dh) { |
| 76 | continue; |
| 108 | if (dh) { |
| 109 | refresh_path(dh, Util::to_wide_str(*it)); |
| 110 | closedir(dh); |
| 111 | } |
| 112 | } |
| 113 | |
| 83 | wstring path(Util::to_wide_str(*it)); |
| 84 | struct dirent *entry; |
| 85 | while ((entry = readdir(dh)) != 0) { |
| 86 | if (entry->d_name[0] == '.') { |
| 87 | continue; |
| 88 | } |
| 89 | |
| 90 | wstring name(Util::to_wide_str(entry->d_name)); |
| 91 | _path_list.push_back(name); |
| 92 | _path_list.push_back(path + L"/" + name); |
| 124 | copy(_path_name_set.begin(), _path_name_set.end(), _path_list.begin()); |
| 125 | _path_list.sort(); |
| 126 | _path_name_set.clear(); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Refresh single directory. |
| 131 | */ |
| 132 | void |
| 133 | PathCompleterMethod::refresh_path(DIR *dh, const std::wstring path) |
| 134 | { |
| 135 | struct dirent *entry; |
| 136 | while ((entry = readdir(dh)) != 0) { |
| 137 | if (entry->d_name[0] == '.') { |
| 138 | continue; |
| 139 | } |
| 140 | |
| 110 | closedir(dh); |
| 142 | wstring name(Util::to_wide_str(entry->d_name)); |
| 143 | _path_name_set.insert(pair<wstring, wstring>(name, name)); |
| 144 | _path_list.push_back(pair<wstring, wstring>(path + L"/" + name, |
| 145 | path + L"/" + name)); |
| 146 | } |
| 147 | } |
| 148 | |
| 118 | _path_list.sort(); |
| 150 | /** |
| 151 | * Check if str matches state prefix. |
| 152 | */ |
| 153 | bool |
| 154 | ActionCompleterMethod::StateMatch::is_state(const wstring &str, size_t pos) |
| 155 | { |
| 156 | if (str.size() - pos < _prefix_len) { |
| 157 | return false; |
| 158 | } else { |
| 159 | return str.compare(pos, _prefix_len, _prefix, _prefix_len) == 0; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Complete action. |
| 165 | */ |
| 166 | unsigned int |
| 167 | ActionCompleterMethod::complete(CompletionState &completion_state) |
| 168 | { |
| 169 | State state = find_state(completion_state); |
| 170 | switch (state) { |
| 171 | case STATE_STATE: |
| 172 | return complete_state(completion_state.word_lower, |
| 173 | completion_state.completions); |
| 174 | #ifdef MENUS |
| 175 | case STATE_MENU: |
| 176 | return complete_menu(completion_state.word_lower, |
| 177 | completion_state.completions); |
| 178 | #endif // MENUS |
| 179 | case STATE_ACTION: |
| 180 | default: |
| 181 | return complete_action(completion_state.word_lower, |
| 182 | completion_state.completions); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Complete state actions. |
| 188 | */ |
| 189 | unsigned int |
| 190 | ActionCompleterMethod::complete_state(const wstring &word, |
| 191 | complete_list &completions) |
| 192 | { |
| 193 | return complete_word(_state_list, completions, word); |
| 194 | } |
| 195 | |
| 196 | #ifdef MENUS |
| 197 | /** |
| 198 | * Complete menu names. |
| 199 | */ |
| 200 | unsigned int |
| 201 | ActionCompleterMethod::complete_menu(const wstring &word, |
| 202 | complete_list &completions) |
| 203 | { |
| 204 | return complete_word(_menu_list, completions, word); |
| 205 | } |
| 206 | #endif // MENUS |
| 207 | |
| 208 | /** |
| 209 | * Complete action names. |
| 210 | */ |
| 211 | unsigned int |
| 212 | ActionCompleterMethod::complete_action(const wstring &word, |
| 213 | complete_list &completions) |
| 214 | { |
| 215 | return complete_word(_action_list, completions, word); |
| 216 | } |
| 217 | |
| 218 | /** |
| ... | |
| 208 | @@ -99,13 +208,72 @@ |
| 208 | ActionCompleterMethod::refresh(void) |
| 209 | { |
| 210 | // Grab list of actions |
| 211 | _action_list.clear(); |
| 212 | Config::action_map_it action_it(Config::instance()->action_map_begin()), action_it_end(Config::instance()->action_map_end()); |
| 213 | for (; action_it != action_it_end; ++action_it) { |
| 214 | if (action_it->second.second&KEYGRABBER_OK) { |
| 106 | _action_list.push_back(Util::to_wide_str(action_it->first.get_text())); |
| 216 | wstring action_name(Util::to_wide_str(action_it->first.get_text())); |
| 217 | wstring action_name_lower(action_name); |
| 218 | Util::to_lower(action_name_lower); |
| 219 | pair<wstring, wstring> action_pair(action_name_lower, action_name); |
| 220 | _action_list.push_back(action_pair); |
| 221 | } |
| 222 | } |
| 223 | _action_list.sort(); |
| 224 | |
| 225 | // Grab list of state actions |
| 226 | _state_list.clear(); |
| 227 | Config::action_state_map_it state_it(Config::instance()->action_state_map_begin()), state_it_end(Config::instance()->action_state_map_end()); |
| 228 | for (; state_it != state_it_end; ++state_it) { |
| 229 | wstring state_name(Util::to_wide_str(state_it->first.get_text())); |
| 230 | wstring state_name_lower(state_name); |
| 231 | Util::to_lower(state_name_lower); |
| 232 | pair<wstring, wstring> state_pair(state_name_lower, state_name); |
| 233 | _state_list.push_back(state_pair); |
| 234 | } |
| 235 | _state_list.sort(); |
| 236 | |
| 237 | #ifdef MENUS |
| 238 | _menu_list.clear(); |
| 239 | list<string> menu_names(MenuHandler::instance()->getMenuNames()); |
| 240 | list<string>::iterator menu_it(menu_names.begin()); |
| 241 | for (; menu_it != menu_names.end(); ++menu_it) { |
| 242 | wstring menu_name(Util::to_wide_str(*menu_it)); |
| 243 | wstring menu_name_lower(menu_name); |
| 244 | Util::to_lower(menu_name_lower); |
| 245 | pair<wstring, wstring> menu_pair(menu_name_lower, menu_name); |
| 246 | _menu_list.push_back(menu_pair); |
| 247 | } |
| 248 | _menu_list.sort(); |
| 249 | #endif // MENUS |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Detect state being completed |
| 254 | */ |
| 255 | ActionCompleterMethod::State |
| 256 | ActionCompleterMethod::find_state(CompletionState &completion_state) |
| 257 | { |
| 258 | State state = STATE_NO; |
| 259 | if (completion_state.word_begin != 0) { |
| 260 | state = find_state_match(completion_state.part_lower, |
| 261 | completion_state.part_begin); |
| 262 | } |
| 263 | return state; |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Find matching state. |
| 268 | */ |
| 269 | ActionCompleterMethod::State |
| 270 | ActionCompleterMethod::find_state_match(const std::wstring &str, size_t pos) |
| 271 | { |
| 272 | for (int i = 0; i < STATE_NUM; ++i) { |
| 273 | if (STATE_MATCHES[i].is_state(str, pos)) { |
| 274 | return STATE_MATCHES[i].get_state(); |
| 275 | } |
| 276 | } |
| 277 | return STATE_NO; |
| 278 | } |
| 279 | |
| 280 | /** |
| ... | |
| 293 | @@ -125,28 +293,28 @@ |
| 293 | complete_list |
| 294 | Completer::find_completions(const wstring &str, unsigned int pos) |
| 295 | { |
| 128 | complete_list completions; |
| 129 | |
| 298 | // Get current part of str, if it is empty return no completions. |
| 131 | size_t part_begin, part_end; |
| 132 | wstring part(get_part(str, pos, part_begin, part_end)); |
| 133 | if (! part.size()) { |
| 134 | return completions; |
| 303 | CompletionState state; |
| 304 | state.part = state.part_lower = get_part(str, pos, state.part_begin, state.part_end); |
| 305 | if (! state.part.size()) { |
| 306 | return state.completions; |
| 307 | } |
| 308 | |
| 309 | // Get word at position, the one that will be completed |
| 142 | size_t word_begin, word_end; |
| 143 | wstring word(get_word_at_position(str, pos, word_begin, word_end)); |
| 312 | state.word = state.word_lower = get_word_at_position(str, pos, state.word_begin, state.word_end); |
| 313 | |
| 314 | Util::to_lower(state.part_lower); |
| 315 | Util::to_lower(state.word_lower); |
| 316 | |
| 317 | // Go through completer methods and add completions. |
| 318 | list<CompleterMethod*>::iterator it(_methods.begin()); |
| 319 | for (; it != _methods.end(); ++it) { |
| 152 | if ((*it)->can_complete(part)) { |
| 153 | (*it)->complete(part, word, completions); |
| 322 | if ((*it)->can_complete(state.part)) { |
| 323 | (*it)->complete(state); |
| 324 | } |
| 325 | } |
| 326 | |
| 159 | return completions; |
| 328 | return state.completions; |
| 329 | } |
| 330 | |
| 331 | /** |
| ... | |
| 326 | @@ -158,7 +326,8 @@ |
| 326 | * @return Completed string. |
| 327 | */ |
| 328 | wstring |
| 161 | Completer::do_complete(const wstring &str, unsigned int &pos, complete_list &completions, complete_it &it) |
| 330 | Completer::do_complete(const wstring &str, unsigned int &pos, |
| 331 | complete_list &completions, complete_it &it) |
| 332 | { |
| 333 | // Do not perform completion if there is nothing to complete |
| 334 | if (! completions.size()) { |
| ... | |
| src/Completer.hh | |
| 16 | @@ -16,8 +16,29 @@ |
| 16 | #include <list> |
| 17 | #include <string> |
| 18 | |
| 19 | extern "C" { |
| 20 | #include <sys/types.h> |
| 21 | #include <dirent.h> |
| 22 | } |
| 23 | |
| 24 | typedef std::list<std::wstring> complete_list; |
| 25 | typedef complete_list::iterator complete_it; |
| 26 | typedef std::list<std::pair<std::wstring, std::wstring> > completions_list; |
| 27 | typedef completions_list::iterator completions_it; |
| 28 | |
| 29 | /** |
| 30 | * State data used during completion. |
| 31 | */ |
| 32 | class CompletionState { |
| 33 | public: |
| 34 | std::wstring part; |
| 35 | std::wstring part_lower; |
| 36 | size_t part_begin, part_end; |
| 37 | std::wstring word; |
| 38 | std::wstring word_lower; |
| 39 | size_t word_begin, word_end; |
| 40 | complete_list completions; |
| 41 | }; |
| 42 | |
| 43 | /** |
| 44 | * Base class for completer methods, provides method to see if it |
| ... | |
| 55 | @@ -34,10 +55,14 @@ |
| 55 | /** Return true if method can complete. */ |
| 56 | virtual bool can_complete(const std::wstring &str) { return false; } |
| 57 | /** Find completions for string. */ |
| 37 | virtual unsigned int complete(const std::wstring &str, const std::wstring &word, |
| 38 | complete_list &completions) { return 0; } |
| 60 | virtual unsigned int complete(CompletionState &completion_state) { return 0; } |
| 61 | /** Refresh completion list. */ |
| 62 | virtual void refresh(void) { } |
| 63 | |
| 64 | protected: |
| 65 | unsigned int complete_word(completions_list &completions_list, |
| 66 | complete_list &completions, |
| 67 | const std::wstring &word); |
| 68 | }; |
| 69 | |
| 70 | /** |
| ... | |
| 74 | @@ -49,8 +74,7 @@ |
| 74 | /** Null completer can always complete. */ |
| 75 | virtual bool can_complete(const std::wstring &str) { return true; } |
| 76 | /** Find completions, does nothing. */ |
| 52 | virtual unsigned int complete(const std::wstring &str, const std::wstring &word, |
| 53 | complete_list &completions) { return 0; } |
| 79 | virtual unsigned int complete(CompletionState &completion_state) { return 0; } |
| 80 | }; |
| 81 | |
| 82 | /** |
| ... | |
| 90 | @@ -66,12 +90,15 @@ |
| 90 | |
| 91 | /** Path completer can always complete. */ |
| 92 | virtual bool can_complete(const std::wstring &str) { return true; } |
| 69 | virtual unsigned int complete(const std::wstring &str, const std::wstring &word, |
| 70 | complete_list &completions); |
| 95 | virtual unsigned int complete(CompletionState &completion_state); |
| 96 | virtual void refresh(void); |
| 97 | |
| 98 | private: |
| 75 | std::list<std::wstring> _path_list; /**< List of all elements in path. */ |
| 100 | void refresh_path(DIR *dh, const std::wstring path); |
| 101 | |
| 102 | private: |
| 103 | completions_list _path_list; /**< List of all elements in path. */ |
| 104 | std::set<std::pair<std::wstring, std::wstring> > _path_name_set; /**< Set with unique names */ |
| 105 | }; |
| 106 | |
| 107 | /** |
| ... | |
| 108 | @@ -81,15 +108,60 @@ |
| 108 | class ActionCompleterMethod : public CompleterMethod |
| 109 | { |
| 110 | public: |
| 111 | /** |
| 112 | * States for context sensitive ActionCompleterMethod completions. |
| 113 | */ |
| 114 | enum State { |
| 115 | STATE_ACTION, |
| 116 | STATE_STATE, |
| 117 | STATE_MENU, |
| 118 | STATE_NO, |
| 119 | STATE_NUM = 5 |
| 120 | }; |
| 121 | |
| 122 | /** |
| 123 | * Context match information. |
| 124 | */ |
| 125 | class StateMatch { |
| 126 | public: |
| 127 | StateMatch(State state, const wchar_t *prefix) |
| 128 | : _prefix(prefix), _prefix_len(wcslen(prefix)), _state(state) { |
| 129 | } |
| 130 | |
| 131 | State get_state(void) { return _state; } |
| 132 | bool is_state(const std::wstring &str, size_t pos); |
| 133 | private: |
| 134 | const wchar_t *_prefix; /**< Matching prefix */ |
| 135 | const size_t _prefix_len; /**< */ |
| 136 | State _state; /**< State */ |
| 137 | }; |
| 138 | |
| 139 | /** Constructor for ActionCompleter method. */ |
| 140 | ActionCompleterMethod(void) : CompleterMethod() { refresh(); } |
| 141 | /** Destructor for ActionCompleterMethod */ |
| 142 | virtual ~ActionCompleterMethod(void) { } |
| 143 | |
| 144 | /** Path completer can always complete. */ |
| 145 | virtual bool can_complete(const std::wstring &str) { return true; } |
| 119 | virtual unsigned int complete(const std::wstring &str, const std::wstring &word, |
| 120 | complete_list &completions); |
| 148 | virtual unsigned int complete(CompletionState &completion_state); |
| 149 | virtual void refresh(void); |
| 150 | |
| 151 | private: |
| 125 | std::list<std::wstring> _action_list; /**< List of all available actions. */ |
| 126 | std::list<std::wstring> _state_param_list; /**< List of parameters to state actions. */ |
| 154 | unsigned int complete_state(const std::wstring &word, complete_list &completions); |
| 155 | unsigned int complete_menu(const std::wstring &word, complete_list &completions); |
| 156 | unsigned int complete_action(const std::wstring &word, complete_list &completions); |
| 157 | |
| 158 | State find_state(CompletionState &completion_state); |
| 159 | size_t find_state_word_start(const std::wstring &str); |
| 160 | State find_state_match(const std::wstring &str, size_t pos); |
| 161 | |
| 162 | private: |
| 163 | completions_list _action_list; /**< List of all available actions. */ |
| 164 | completions_list _state_list; /**< List of parameters to state actions. */ |
| 165 | #ifdef MENUS |
| 166 | completions_list _menu_list; /**< List of parameters to state actions. */ |
| 167 | #endif // MENUS |
| 168 | static StateMatch STATE_MATCHES[]; /**< List of known states with matching data. */ |
| 169 | }; |
| 170 | |
| 171 | /** |
| ... | |
| src/CmdDialog.cc | |
| 48 | @@ -48,6 +48,7 @@ |
| 48 | _type = PWinObj::WO_CMD_DIALOG; |
| 49 | |
| 50 | // Setup completer |
| 51 | _completer.add_method(new ActionCompleterMethod()); |
| 52 | _completer.add_method(new PathCompleterMethod()); |
| 53 | |
| 54 | if (Config::instance()->getCmdDialogHistoryFile().size() > 0) { |
| ... | |
| src/Config.cc | |
| 122 | @@ -122,58 +122,58 @@ |
| 122 | |
| 123 | // fill parsing maps |
| 124 | _action_map[""] = pair<ActionType, uint>(ACTION_NO, 0); |
| 125 | _action_map["FOCUS"] = pair<ActionType, uint>(ACTION_FOCUS, ANY_MASK); |
| 126 | _action_map["UNFOCUS"] = pair<ActionType, uint>(ACTION_UNFOCUS, ANY_MASK); |
| 127 | |
| 128 | _action_map["SET"] = pair<ActionType, uint>(ACTION_SET, ANY_MASK); |
| 129 | _action_map["UNSET"] = pair<ActionType, uint>(ACTION_UNSET, ANY_MASK); |
| 130 | _action_map["TOGGLE"] = pair<ActionType, uint>(ACTION_TOGGLE, ANY_MASK); |
| 131 | |
| 132 | _action_map["MAXFILL"] = pair<ActionType, uint>(ACTION_MAXFILL, FRAME_MASK); |
| 133 | _action_map["GROWDIRECTION"] = pair<ActionType, uint>(ACTION_GROW_DIRECTION, FRAME_MASK); |
| 134 | _action_map["CLOSE"] = pair<ActionType, uint>(ACTION_CLOSE, FRAME_MASK); |
| 135 | _action_map["CLOSEFRAME"] = pair<ActionType, uint>(ACTION_CLOSE_FRAME, FRAME_MASK); |
| 136 | _action_map["KILL"] = pair<ActionType, uint>(ACTION_KILL, FRAME_MASK); |
| 137 | _action_map["RAISE"] = pair<ActionType, uint>(ACTION_RAISE, FRAME_MASK); |
| 138 | _action_map["LOWER"] = pair<ActionType, uint>(ACTION_LOWER, FRAME_MASK); |
| 139 | _action_map["ACTIVATEORRAISE"] = pair<ActionType, uint>(ACTION_ACTIVATE_OR_RAISE, FRAME_MASK); |
| 140 | _action_map["ACTIVATECLIENTREL"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT_REL, FRAME_MASK); |
| 141 | _action_map["MOVECLIENTREL"] = pair<ActionType, uint>(ACTION_MOVE_CLIENT_REL, FRAME_MASK); |
| 142 | _action_map["ACTIVATECLIENT"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT, FRAME_MASK); |
| 143 | _action_map["ACTIVATECLIENTNUM"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT_NUM, KEYGRABBER_OK); |
| 144 | _action_map["RESIZE"] = pair<ActionType, uint>(ACTION_RESIZE, BUTTONCLICK_OK|CLIENT_OK|FRAME_OK|FRAME_BORDER_OK); |
| 145 | _action_map["MOVE"] = pair<ActionType, uint>(ACTION_MOVE, FRAME_OK|FRAME_BORDER_OK|CLIENT_OK); |
| 146 | _action_map["MOVERESIZE"] = pair<ActionType, uint>(ACTION_MOVE_RESIZE, KEYGRABBER_OK); |
| 147 | _action_map["GROUPINGDRAG"] = pair<ActionType, uint>(ACTION_GROUPING_DRAG, FRAME_OK|CLIENT_OK); |
| 148 | _action_map["WARPTOWORKSPACE"] = pair<ActionType, uint>(ACTION_WARP_TO_WORKSPACE, SCREEN_EDGE_OK); |
| 149 | _action_map["MOVETOEDGE"] = pair<ActionType, uint>(ACTION_MOVE_TO_EDGE, KEYGRABBER_OK); |
| 150 | _action_map["NEXTFRAME"] = pair<ActionType, uint>(ACTION_NEXT_FRAME, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 151 | _action_map["PREVFRAME"] = pair<ActionType, uint>(ACTION_PREV_FRAME, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 152 | _action_map["NEXTFRAMEMRU"] = pair<ActionType, uint>(ACTION_NEXT_FRAME_MRU, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 153 | _action_map["PREVFRAMEMRU"] = pair<ActionType, uint>(ACTION_PREV_FRAME_MRU, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 154 | _action_map["FOCUSDIRECTIONAL"] = pair<ActionType, uint>(ACTION_FOCUS_DIRECTIONAL, FRAME_MASK); |
| 155 | _action_map["ATTACHMARKED"] = pair<ActionType, uint>(ACTION_ATTACH_MARKED, FRAME_MASK); |
| 156 | _action_map["ATTACHCLIENTINNEXTFRAME"] = pair<ActionType, uint>(ACTION_ATTACH_CLIENT_IN_NEXT_FRAME, FRAME_MASK); |
| 157 | _action_map["ATTACHCLIENTINPREVFRAME"] = pair<ActionType, uint>(ACTION_ATTACH_CLIENT_IN_PREV_FRAME, FRAME_MASK); |
| 158 | _action_map["FINDCLIENT"] = pair<ActionType, uint>(ACTION_FIND_CLIENT, ANY_MASK); |
| 159 | _action_map["GOTOCLIENTID"] = pair<ActionType, uint>(ACTION_GOTO_CLIENT_ID, ANY_MASK); |
| 160 | _action_map["DETACH"] = pair<ActionType, uint>(ACTION_DETACH, FRAME_MASK); |
| 161 | _action_map["SENDTOWORKSPACE"] = pair<ActionType, uint>(ACTION_SEND_TO_WORKSPACE, ANY_MASK); |
| 162 | _action_map["GOTOWORKSPACE"] = pair<ActionType, uint>(ACTION_GOTO_WORKSPACE, ANY_MASK ); |
| 163 | _action_map["EXEC"] = pair<ActionType, uint>(ACTION_EXEC, FRAME_MASK|ROOTMENU_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 164 | _action_map["RELOAD"] = pair<ActionType, uint>(ACTION_RELOAD, KEYGRABBER_OK|ROOTMENU_OK); |
| 165 | _action_map["RESTART"] = pair<ActionType, uint>(ACTION_RESTART, KEYGRABBER_OK|ROOTMENU_OK); |
| 166 | _action_map["RESTARTOTHER"] = pair<ActionType, uint>(ACTION_RESTART_OTHER, KEYGRABBER_OK|ROOTMENU_OK); |
| 167 | _action_map["EXIT"] = pair<ActionType, uint>(ACTION_EXIT, KEYGRABBER_OK|ROOTMENU_OK); |
| 168 | _action_map["SHOWCMDDIALOG"] = pair<ActionType, uint>(ACTION_SHOW_CMD_DIALOG, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 169 | _action_map["SHOWSEARCHDIALOG"] = pair<ActionType, uint>(ACTION_SHOW_SEARCH_DIALOG, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 170 | _action_map["Focus"] = pair<ActionType, uint>(ACTION_FOCUS, ANY_MASK); |
| 171 | _action_map["UnFocus"] = pair<ActionType, uint>(ACTION_UNFOCUS, ANY_MASK); |
| 172 | |
| 173 | _action_map["Set"] = pair<ActionType, uint>(ACTION_SET, ANY_MASK); |
| 174 | _action_map["Unset"] = pair<ActionType, uint>(ACTION_UNSET, ANY_MASK); |
| 175 | _action_map["Toggle"] = pair<ActionType, uint>(ACTION_TOGGLE, ANY_MASK); |
| 176 | |
| 177 | _action_map["MaxFill"] = pair<ActionType, uint>(ACTION_MAXFILL, FRAME_MASK); |
| 178 | _action_map["GrowDirection"] = pair<ActionType, uint>(ACTION_GROW_DIRECTION, FRAME_MASK); |
| 179 | _action_map["Close"] = pair<ActionType, uint>(ACTION_CLOSE, FRAME_MASK); |
| 180 | _action_map["CloseFrame"] = pair<ActionType, uint>(ACTION_CLOSE_FRAME, FRAME_MASK); |
| 181 | _action_map["Kill"] = pair<ActionType, uint>(ACTION_KILL, FRAME_MASK); |
| 182 | _action_map["Raise"] = pair<ActionType, uint>(ACTION_RAISE, FRAME_MASK); |
| 183 | _action_map["Lower"] = pair<ActionType, uint>(ACTION_LOWER, FRAME_MASK); |
| 184 | _action_map["ActivateOrRaise"] = pair<ActionType, uint>(ACTION_ACTIVATE_OR_RAISE, FRAME_MASK); |
| 185 | _action_map["ActivateClientRel"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT_REL, FRAME_MASK); |
| 186 | _action_map["MoveClientRel"] = pair<ActionType, uint>(ACTION_MOVE_CLIENT_REL, FRAME_MASK); |
| 187 | _action_map["ActivateClient"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT, FRAME_MASK); |
| 188 | _action_map["ActivateClientNum"] = pair<ActionType, uint>(ACTION_ACTIVATE_CLIENT_NUM, KEYGRABBER_OK); |
| 189 | _action_map["Resize"] = pair<ActionType, uint>(ACTION_RESIZE, BUTTONCLICK_OK|CLIENT_OK|FRAME_OK|FRAME_BORDER_OK); |
| 190 | _action_map["Move"] = pair<ActionType, uint>(ACTION_MOVE, FRAME_OK|FRAME_BORDER_OK|CLIENT_OK); |
| 191 | _action_map["MoveResize"] = pair<ActionType, uint>(ACTION_MOVE_RESIZE, KEYGRABBER_OK); |
| 192 | _action_map["GroupingDrag"] = pair<ActionType, uint>(ACTION_GROUPING_DRAG, FRAME_OK|CLIENT_OK); |
| 193 | _action_map["WarpToWorkspace"] = pair<ActionType, uint>(ACTION_WARP_TO_WORKSPACE, SCREEN_EDGE_OK); |
| 194 | _action_map["MoveToEdge"] = pair<ActionType, uint>(ACTION_MOVE_TO_EDGE, KEYGRABBER_OK); |
| 195 | _action_map["NextFrame"] = pair<ActionType, uint>(ACTION_NEXT_FRAME, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 196 | _action_map["PrevFrame"] = pair<ActionType, uint>(ACTION_PREV_FRAME, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 197 | _action_map["NextFrameMRU"] = pair<ActionType, uint>(ACTION_NEXT_FRAME_MRU, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 198 | _action_map["PrevFrameMRU"] = pair<ActionType, uint>(ACTION_PREV_FRAME_MRU, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 199 | _action_map["FocusDirectional"] = pair<ActionType, uint>(ACTION_FOCUS_DIRECTIONAL, FRAME_MASK); |
| 200 | _action_map["AttachMarked"] = pair<ActionType, uint>(ACTION_ATTACH_MARKED, FRAME_MASK); |
| 201 | _action_map["AttachClientInNextFrame"] = pair<ActionType, uint>(ACTION_ATTACH_CLIENT_IN_NEXT_FRAME, FRAME_MASK); |
| 202 | _action_map["AttachClientInPrevFrame"] = pair<ActionType, uint>(ACTION_ATTACH_CLIENT_IN_PREV_FRAME, FRAME_MASK); |
| 203 | _action_map["FindClient"] = pair<ActionType, uint>(ACTION_FIND_CLIENT, ANY_MASK); |
| 204 | _action_map["GotoClientID"] = pair<ActionType, uint>(ACTION_GOTO_CLIENT_ID, ANY_MASK); |
| 205 | _action_map["Detach"] = pair<ActionType, uint>(ACTION_DETACH, FRAME_MASK); |
| 206 | _action_map["SendToWorkspace"] = pair<ActionType, uint>(ACTION_SEND_TO_WORKSPACE, ANY_MASK); |
| 207 | _action_map["GoToWorkspace"] = pair<ActionType, uint>(ACTION_GOTO_WORKSPACE, ANY_MASK ); |
| 208 | _action_map["Exec"] = pair<ActionType, uint>(ACTION_EXEC, FRAME_MASK|ROOTMENU_OK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 209 | _action_map["Reload"] = pair<ActionType, uint>(ACTION_RELOAD, KEYGRABBER_OK|ROOTMENU_OK); |
| 210 | _action_map["Restart"] = pair<ActionType, uint>(ACTION_RESTART, KEYGRABBER_OK|ROOTMENU_OK); |
| 211 | _action_map["RestartOther"] = pair<ActionType, uint>(ACTION_RESTART_OTHER, KEYGRABBER_OK|ROOTMENU_OK); |
| 212 | _action_map["Exit"] = pair<ActionType, uint>(ACTION_EXIT, KEYGRABBER_OK|ROOTMENU_OK); |
| 213 | _action_map["ShowCmdDialog"] = pair<ActionType, uint>(ACTION_SHOW_CMD_DIALOG, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 214 | _action_map["ShowSearchDialog"] = pair<ActionType, uint>(ACTION_SHOW_SEARCH_DIALOG, KEYGRABBER_OK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 215 | #ifdef MENUS |
| 216 | _action_map["SHOWMENU"] = pair<ActionType, uint>(ACTION_SHOW_MENU, FRAME_MASK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 217 | _action_map["HIDEALLMENUS"] = pair<ActionType, uint>(ACTION_HIDE_ALL_MENUS, FRAME_MASK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 218 | _action_map["SUBMENU"] = pair<ActionType, uint>(ACTION_MENU_SUB, ROOTMENU_OK|WINDOWMENU_OK); |
| 219 | _action_map["DYNAMIC"] = pair<ActionType, uint>(ACTION_MENU_DYN, ROOTMENU_OK|WINDOWMENU_OK); |
| 220 | _action_map["ShowMenu"] = pair<ActionType, uint>(ACTION_SHOW_MENU, FRAME_MASK|ROOTCLICK_OK|SCREEN_EDGE_OK|ROOTMENU_OK|WINDOWMENU_OK); |
| 221 | _action_map["HideAllMenus"] = pair<ActionType, uint>(ACTION_HIDE_ALL_MENUS, FRAME_MASK|ROOTCLICK_OK|SCREEN_EDGE_OK); |
| 222 | _action_map["SubMenu"] = pair<ActionType, uint>(ACTION_MENU_SUB, ROOTMENU_OK|WINDOWMENU_OK); |
| 223 | _action_map["Dynamic"] = pair<ActionType, uint>(ACTION_MENU_DYN, ROOTMENU_OK|WINDOWMENU_OK); |
| 224 | #endif // MENUS |
| 225 | _action_map["SENDKEY"] = pair<ActionType, uint>(ACTION_SEND_KEY, ANY_MASK); |
| 226 | _action_map["SendKey"] = pair<ActionType, uint>(ACTION_SEND_KEY, ANY_MASK); |
| 227 | |
| 228 | _placement_map[""] = PLACE_NO; |
| 229 | _placement_map["SMART"] = PLACE_SMART; |
| ... | |
| 292 | @@ -292,24 +292,24 @@ |
| 292 | _mod_map["ANY"] = MOD_ANY; |
| 293 | |
| 294 | _action_state_map[""] = ACTION_STATE_NO; |
| 295 | _action_state_map["MAXIMIZED"] = ACTION_STATE_MAXIMIZED; |
| 296 | _action_state_map["FULLSCREEN"] = ACTION_STATE_FULLSCREEN; |
| 297 | _action_state_map["SHADED"] = ACTION_STATE_SHADED; |
| 298 | _action_state_map["STICKY"] = ACTION_STATE_STICKY; |
| 299 | _action_state_map["ALWAYSONTOP"] = ACTION_STATE_ALWAYS_ONTOP; |
| 300 | _action_state_map["ALWAYSBELOW"] = ACTION_STATE_ALWAYS_BELOW; |
| 301 | _action_state_map["DECORBORDER"] = ACTION_STATE_DECOR_BORDER; |
| 302 | _action_state_map["DECORTITLEBAR"] = ACTION_STATE_DECOR_TITLEBAR; |
| 303 | _action_state_map["ICONIFIED"] = ACTION_STATE_ICONIFIED; |
| 304 | _action_state_map["TAGGED"] = ACTION_STATE_TAGGED; |
| 305 | _action_state_map["MARKED"] = ACTION_STATE_MARKED; |
| 306 | _action_state_map["SKIP"] = ACTION_STATE_SKIP; |
| 307 | _action_state_map["CFGDENY"] = ACTION_STATE_CFG_DENY; |
| 308 | _action_state_map["TITLE"] = ACTION_STATE_TITLE; |
| 309 | _action_state_map["Maximized"] = ACTION_STATE_MAXIMIZED; |
| 310 | _action_state_map["Fullscreen"] = ACTION_STATE_FULLSCREEN; |
| 311 | _action_state_map["Shaded"] = ACTION_STATE_SHADED; |
| 312 | _action_state_map["Sticky"] = ACTION_STATE_STICKY; |
| 313 | _action_state_map["AlwaysOnTop"] = ACTION_STATE_ALWAYS_ONTOP; |
| 314 | _action_state_map["AlwaysBelow"] = ACTION_STATE_ALWAYS_BELOW; |
| 315 | _action_state_map["DecorBorder"] = ACTION_STATE_DECOR_BORDER; |
| 316 | _action_state_map["DecorTitlebar"] = ACTION_STATE_DECOR_TITLEBAR; |
| 317 | _action_state_map["Iconified"] = ACTION_STATE_ICONIFIED; |
| 318 | _action_state_map["Tagged"] = ACTION_STATE_TAGGED; |
| 319 | _action_state_map["Marked"] = ACTION_STATE_MARKED; |
| 320 | _action_state_map["Skip"] = ACTION_STATE_SKIP; |
| 321 | _action_state_map["CfgDeny"] = ACTION_STATE_CFG_DENY; |
| 322 | _action_state_map["Title"] = ACTION_STATE_TITLE; |
| 323 | #ifdef HARBOUR |
| 324 | _action_state_map["HARBOURHIDDEN"] = ACTION_STATE_HARBOUR_HIDDEN; |
| 325 | _action_state_map["HarbourHidden"] = ACTION_STATE_HARBOUR_HIDDEN; |
| 326 | #endif // HARBOUR |
| 327 | _action_state_map["GLOBALGROUPING"] = ACTION_STATE_GLOBAL_GROUPING; |
| 328 | _action_state_map["GlobalGrouping"] = ACTION_STATE_GLOBAL_GROUPING; |
| 329 | |
| 330 | |
| 331 | _cfg_deny_map["POSITION"] = CFG_DENY_POSITION; |
| ... | |
| src/Config.hh | |
| 66 | @@ -66,6 +66,7 @@ |
| 66 | { |
| 67 | public: |
| 68 | typedef std::map<ParseUtil::Entry, std::pair<ActionType, uint> >::iterator action_map_it; |
| 69 | typedef std::map<ParseUtil::Entry, ActionStateType>::iterator action_state_map_it; |
| 70 | |
| 71 | Config(void); |
| 72 | ~Config(void); |
| ... | |
| 83 | @@ -82,6 +83,11 @@ |
| 83 | /** Return end iterator for iterating over actions. */ |
| 84 | action_map_it action_map_end(void) { return _action_map.end(); } |
| 85 | |
| 86 | /** Return start iterator for iterating over state actions. */ |
| 87 | action_state_map_it action_state_map_begin(void) { return _action_state_map.begin(); } |
| 88 | /** Return end iterator for iterating over state actions. */ |
| 89 | action_state_map_it action_state_map_end(void) { return _action_state_map.end(); } |
| 90 | |
| 91 | // Files |
| 92 | const std::string &getKeyFile(void) const { return _files_keys; } |
| 93 | const std::string &getMenuFile(void) const { return _files_menu; } |
| ... | |
| src/Util.hh | |
| 83 | @@ -83,6 +83,25 @@ |
| 83 | std::transform(str.begin(), str.end(), str.begin(), (int(*)(int)) std::tolower); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Converts wide string to uppercase |
| 88 | * |
| 89 | * @param str Reference to the string to convert |
| 90 | */ |
| 91 | inline void to_upper(std::wstring &str) { |
| 92 | std::transform(str.begin(), str.end(), str.begin(), (int(*)(int)) std::towupper); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | /** |
| 97 | * Converts wide string to lowercase |
| 98 | * |
| 99 | * @param str Reference to the string to convert |
| 100 | */ |
| 101 | inline void to_lower(std::wstring &str) { |
| 102 | std::transform(str.begin(), str.end(), str.begin(), (int(*)(int)) std::towlower); |
| 103 | } |
| 104 | |
| 105 | std::string to_mb_str(const std::wstring &str); |
| 106 | std::wstring to_wide_str(const std::string &str); |
| 107 | |
| ... | |