| 157 | } |
| 158 | |
| 159 | void C_TabComplete (bool goForward) |
| 160 | { |
| 161 | unsigned i; |
| 162 | int diffpoint; |
| 163 | |
| 164 | auto CmdLineText = CmdLine.GetText(); |
| 165 | if (!TabbedLast) |
| 166 | { |
| 167 | bool cancomplete; |
| 168 | |
| 169 | |
| 170 | // Skip any spaces at beginning of command line |
| 171 | for (i = 0; i < CmdLineText.Len(); ++i) |
| 172 | { |
| 173 | if (CmdLineText[i] != ' ') |
| 174 | break; |
| 175 | } |
| 176 | if (i == CmdLineText.Len()) |
| 177 | { // Line was nothing but spaces |
| 178 | return; |
| 179 | } |
| 180 | TabStart = i; |
| 181 | |
| 182 | TabSize = (int)CmdLineText.Len() - TabStart; |
| 183 | |
| 184 | if (!FindTabCommand(&CmdLineText[TabStart], &TabPos, TabSize)) |
| 185 | return; // No initial matches |
| 186 | |
| 187 | // Show a list of possible completions, if more than one. |
| 188 | if (TabbedList || con_notablist) |
| 189 | { |
| 190 | cancomplete = true; |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | cancomplete = C_TabCompleteList (); |
| 195 | TabbedList = true; |
| 196 | } |
| 197 | |
| 198 | if (goForward) |
| 199 | { // Position just before the list of completions so that when TabPos |
| 200 | // gets advanced below, it will be at the first one. |
| 201 | --TabPos; |
| 202 | } |
| 203 | else |
| 204 | { // Find the last matching tab, then go one past it. |
| 205 | while (++TabPos < (int)TabCommands.Size()) |
| 206 | { |
| 207 | if (FindDiffPoint(TabCommands[TabPos].TabName, &CmdLineText[TabStart]) < TabSize) |
| 208 | { |
| 209 | break; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | TabbedLast = true; |
| 214 | if (!cancomplete) |
| 215 | { |
| 216 | return; |
no test coverage detected