Rename cache{Prefix,Substr} to cache{Complete,Search}
parent
14a6486b9b
commit
b373a5c091
4
cache.c
4
cache.c
|
@ -130,7 +130,7 @@ enum Color cacheColor(uint id, const char *key) {
|
|||
return (node ? node->color : Default);
|
||||
}
|
||||
|
||||
const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix) {
|
||||
const char *cacheComplete(struct Cursor *curs, uint id, const char *prefix) {
|
||||
size_t len = strlen(prefix);
|
||||
if (curs->gen != gen) curs->node = NULL;
|
||||
for (
|
||||
|
@ -145,7 +145,7 @@ const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char *cacheSubstr(struct Cursor *curs, uint id, const char *substr) {
|
||||
const char *cacheSearch(struct Cursor *curs, uint id, const char *substr) {
|
||||
if (curs->gen != gen) curs->node = NULL;
|
||||
for (
|
||||
curs->gen = gen, curs->node = (curs->node ? curs->node->next : head);
|
||||
|
|
4
chat.h
4
chat.h
|
@ -404,8 +404,8 @@ void cacheInsert(bool touch, uint id, const char *key);
|
|||
void cacheInsertColor(bool touch, uint id, const char *key, enum Color color);
|
||||
void cacheReplace(bool touch, const char *old, const char *new);
|
||||
enum Color cacheColor(uint id, const char *key);
|
||||
const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix);
|
||||
const char *cacheSubstr(struct Cursor *curs, uint id, const char *substr);
|
||||
const char *cacheComplete(struct Cursor *curs, uint id, const char *prefix);
|
||||
const char *cacheSearch(struct Cursor *curs, uint id, const char *substr);
|
||||
uint cacheID(struct Cursor *curs, const char *key);
|
||||
void cacheAccept(struct Cursor *curs);
|
||||
void cacheReject(struct Cursor *curs);
|
||||
|
|
|
@ -397,7 +397,7 @@ static void commandWindow(uint id, char *params) {
|
|||
return;
|
||||
}
|
||||
struct Cursor curs = {0};
|
||||
for (const char *match; (match = cacheSubstr(&curs, None, params));) {
|
||||
for (const char *match; (match = cacheSearch(&curs, None, params));) {
|
||||
id = idFind(match);
|
||||
if (!id) continue;
|
||||
cacheAccept(&curs);
|
||||
|
@ -672,8 +672,8 @@ void command(uint id, char *input) {
|
|||
|
||||
struct Cursor curs = {0};
|
||||
const char *cmd = strsep(&input, " ");
|
||||
const char *unique = cachePrefix(&curs, None, cmd);
|
||||
if (unique && !cachePrefix(&curs, None, cmd)) {
|
||||
const char *unique = cacheComplete(&curs, None, cmd);
|
||||
if (unique && !cacheComplete(&curs, None, cmd)) {
|
||||
cmd = unique;
|
||||
}
|
||||
|
||||
|
|
4
handle.c
4
handle.c
|
@ -641,7 +641,7 @@ static void handleReplyNoTopic(struct Message *msg) {
|
|||
static void topicCache(uint id, const char *topic) {
|
||||
char buf[512];
|
||||
struct Cursor curs = {0};
|
||||
const char *prev = cachePrefix(&curs, id, "/topic ");
|
||||
const char *prev = cacheComplete(&curs, id, "/topic ");
|
||||
if (prev) {
|
||||
snprintf(buf, sizeof(buf), "%s", prev);
|
||||
cacheRemove(id, buf);
|
||||
|
@ -720,7 +720,7 @@ static void handleTopic(struct Message *msg) {
|
|||
}
|
||||
|
||||
struct Cursor curs = {0};
|
||||
const char *prev = cachePrefix(&curs, id, "/topic ");
|
||||
const char *prev = cacheComplete(&curs, id, "/topic ");
|
||||
if (prev) {
|
||||
prev += 7;
|
||||
} else {
|
||||
|
|
4
input.c
4
input.c
|
@ -333,9 +333,9 @@ static int tabComplete(struct Edit *e, uint id) {
|
|||
tab.suffix = true;
|
||||
}
|
||||
|
||||
const char *comp = cachePrefix(&tab.curs, id, tab.pre);
|
||||
const char *comp = cacheComplete(&tab.curs, id, tab.pre);
|
||||
if (!comp) {
|
||||
comp = cachePrefix(&tab.curs, id, tab.pre);
|
||||
comp = cacheComplete(&tab.curs, id, tab.pre);
|
||||
tab.suffix ^= true;
|
||||
}
|
||||
if (!comp) {
|
||||
|
|
Loading…
Reference in New Issue