Cube  Check-in [2200947ce9]

Overview
Comment:Fix tab completion
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2200947ce957ddb35e68f3d631cc4b7171394ea06302fdb9ce624f1aebf8584c
User & Date: js on 2025-03-12 23:28:37
Other Links: manifest | tags
Context
2025-03-15
00:24
More string migrations check-in: 5659be76db user: js tags: trunk
2025-03-12
23:28
Fix tab completion check-in: 2200947ce9 user: js tags: trunk
23:06
Default to -O2 check-in: 50af4ea0ff user: js tags: trunk
Changes

Modified src/commands.mm from [e9b116439f] to [d5247fc383].

294
295
296
297
298
299
300
301

302
303
304
305
306

307
308

309
310
311
312
313


314
315
316
317
318

319
320
321
322
323
324
325
326
327
328
329






330
331
332
333
334
335
336
337
294
295
296
297
298
299
300

301
302
303



304


305





306
307

308
309
310

311
312
313
314
315
316
317





318
319
320
321
322
323

324
325
326
327
328
329
330







-
+


-
-
-
+
-
-
+
-
-
-
-
-
+
+
-



-
+






-
-
-
-
-
+
+
+
+
+
+
-







void
resetcomplete()
{
	completesize = 0;
}

void
complete(OFString *s_)
complete(OFMutableString *s)
{
	@autoreleasepool {
		std::unique_ptr<char> copy(strdup(s_.UTF8String));
		char *s = copy.get();

		if (![s hasPrefix:@"/"])
		if (*s != '/') {
			string t;
			[s insertString:@"/" atIndex:0];
			strcpy_s(t, s);
			strcpy_s(s, "/");
			strcat_s(s, t);
		}


		if (s.length == 1)
		if (!s[1])
			return;

		if (!completesize) {
			completesize = strlen(s) - 1;
			completesize = s.length - 1;
			completeidx = 0;
		}

		__block int idx = 0;
		[identifiers enumerateKeysAndObjectsUsingBlock:^(
		    OFString *name, Identifier *identifier, bool *stop) {
			if (strncmp(identifier.name.UTF8String, s + 1,
			        completesize) == 0 &&
			    idx++ == completeidx) {
				strcpy_s(s, "/");
				strcat_s(s, identifier.name.UTF8String);
			if (strncmp(identifier.name.UTF8String,
			        s.UTF8String + 1, completesize) == 0 &&
			    idx++ == completeidx)
				[s replaceCharactersInRange:OFMakeRange(
				                                1, s.length - 1)
				                 withString:identifier.name];
			}
		}];

		completeidx++;

		if (completeidx >= idx)
			completeidx = 0;
	}

Modified src/protos.h from [442aaeb8db] to [2b4f29b604].

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete();
extern void complete(OFString *s);
extern void complete(OFMutableString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();

// console
extern void keypress(int code, bool isDown);
extern void input(OFString *text);