Mercurial > hg > nnchat
comparison main.c @ 429:2ac24f1e241b
Start working on command completion.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 May 2012 13:05:31 +0300 |
parents | 341ac6f99439 |
children | aaadf6cea6be |
comparison
equal
deleted
inserted
replaced
428:162011bbec48 | 429:2ac24f1e241b |
---|---|
1334 | 1334 |
1335 | 1335 |
1336 BOOL performTabCompletion(nn_editbuf_t *buf) | 1336 BOOL performTabCompletion(nn_editbuf_t *buf) |
1337 { | 1337 { |
1338 static char *previous = NULL, *pattern = NULL; | 1338 static char *previous = NULL, *pattern = NULL; |
1339 BOOL again = FALSE, hasSeparator = FALSE, newPattern = FALSE, hasSpace = FALSE; | 1339 BOOL again = FALSE, hasSeparator = FALSE, |
1340 newPattern = FALSE, hasSpace = FALSE, isCommand; | |
1340 char *str = buf->data; | 1341 char *str = buf->data; |
1341 int mode = 0; | 1342 int mode = 0; |
1342 ssize_t endPos, startPos = buf->pos; | 1343 ssize_t endPos, startPos = buf->pos; |
1343 | 1344 |
1344 // previous word | 1345 // previous word |
1374 if (optDebug) | 1375 if (optDebug) |
1375 printMsg(currWin, "no mode\n"); | 1376 printMsg(currWin, "no mode\n"); |
1376 return FALSE; | 1377 return FALSE; |
1377 } | 1378 } |
1378 | 1379 |
1379 if (str[endPos] == optNickSep) | 1380 // Check if this is a command completion |
1381 isCommand = (str[0] == '/' && startPos == 0); | |
1382 | |
1383 if (!isCommand && str[endPos] == optNickSep) | |
1380 { | 1384 { |
1381 endPos--; | 1385 endPos--; |
1382 if (startPos > 0) | 1386 if (startPos > 0) |
1383 { | 1387 { |
1384 if (optDebug) | 1388 if (optDebug) |
1418 hasSeparator ? "yes" : "no", | 1422 hasSeparator ? "yes" : "no", |
1419 hasSpace ? "yes" : "no", | 1423 hasSpace ? "yes" : "no", |
1420 newPattern ? "yes" : "no", mode); | 1424 newPattern ? "yes" : "no", mode); |
1421 } | 1425 } |
1422 | 1426 |
1423 if (pattern) | 1427 if (!pattern) |
1428 return FALSE; | |
1429 | |
1430 if (isCommand) | |
1431 { | |
1432 /* | |
1433 int i; | |
1434 for (i = 0; i < nuserCmds; i++) | |
1435 { | |
1436 if (nncmd_match(pattern, | |
1437 } | |
1438 */ | |
1439 } | |
1440 else | |
1424 { | 1441 { |
1425 nn_user_t *user = nn_user_match(nnUsers, pattern, previous, again); | 1442 nn_user_t *user = nn_user_match(nnUsers, pattern, previous, again); |
1426 | 1443 |
1427 if (user) | 1444 if (user) |
1428 { | 1445 { |