MCPcopy Create free account
hub / github.com/ZDoom/Raze / C_TabComplete

Function C_TabComplete

source/common/console/c_tabcomplete.cpp:159–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void 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;

Callers 1

C_HandleKeyFunction · 0.85

Calls 10

FindTabCommandFunction · 0.85
C_TabCompleteListFunction · 0.85
FindDiffPointFunction · 0.85
LenMethod · 0.80
TruncateMethod · 0.80
MakeStartPosGoodMethod · 0.80
GetTextMethod · 0.45
SizeMethod · 0.45
GetCharsMethod · 0.45
SetStringMethod · 0.45

Tested by

no test coverage detected