| 35 | } |
| 36 | |
| 37 | void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) |
| 38 | { |
| 39 | if (!this->GetString()) { |
| 40 | return; |
| 41 | } |
| 42 | FORM* form = fm->GetForm(); |
| 43 | form_driver(form, REQ_NEXT_FIELD); |
| 44 | form_driver(form, REQ_PREV_FIELD); |
| 45 | std::string cstr = this->GetString(); |
| 46 | cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r") + 1); |
| 47 | if (this->LastString != cstr) { |
| 48 | this->Cycle = false; |
| 49 | this->CurrentIndex = 0; |
| 50 | this->LastGlob = ""; |
| 51 | } |
| 52 | std::string glob; |
| 53 | if (this->Cycle) { |
| 54 | glob = this->LastGlob; |
| 55 | } else { |
| 56 | glob = cstr + "*"; |
| 57 | } |
| 58 | std::vector<std::string> dirs; |
| 59 | |
| 60 | cmSystemTools::SimpleGlob(glob, dirs, |
| 61 | (this->Type == cmStateEnums::PATH ? -1 : 0)); |
| 62 | if (this->CurrentIndex < dirs.size()) { |
| 63 | cstr = dirs[this->CurrentIndex]; |
| 64 | } |
| 65 | if (cstr[cstr.size() - 1] == '*') { |
| 66 | cstr = cstr.substr(0, cstr.size() - 1); |
| 67 | } |
| 68 | |
| 69 | if (cmSystemTools::FileIsDirectory(cstr)) { |
| 70 | cstr += "/"; |
| 71 | } |
| 72 | |
| 73 | this->SetString(cstr); |
| 74 | touchwin(w); |
| 75 | wrefresh(w); |
| 76 | form_driver(form, REQ_END_FIELD); |
| 77 | this->LastGlob = glob; |
| 78 | this->LastString = cstr; |
| 79 | this->Cycle = true; |
| 80 | this->CurrentIndex++; |
| 81 | if (this->CurrentIndex >= dirs.size()) { |
| 82 | this->CurrentIndex = 0; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void cmCursesPathWidget::OnReturn(cmCursesMainForm* fm, WINDOW* w) |
| 87 | { |
nothing calls this directly
no test coverage detected