1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-13 00:53:01 +01:00

no trailing space for command tab-complete

This commit is contained in:
Jfreegman 2014-06-02 03:19:59 -04:00
parent 4d249c5fe3
commit f9e15cd60b
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
3 changed files with 19 additions and 8 deletions

View File

@ -212,7 +212,7 @@ static int nodelist_load(char *filename)
if (name == NULL || port == NULL || key_ascii == NULL)
continue;
strncpy(nodes[linecnt], name, NODELEN);
snprintf(nodes[linecnt], sizeof(nodes[linecnt]), "%s", name);
nodes[linecnt][NODELEN - 1] = 0;
ports[linecnt] = htons(atoi(port));

View File

@ -195,19 +195,31 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
uint8_t tmp[MAX_STR_SIZE];
snprintf(tmp, sizeof(tmp), "%s", ubuf);
tmp[*pos] = '\0';
int n_endchrs = 1; /* 1 = append space to end of match, 2 = append ": ", 0 = append nothing */
const uint8_t *endchrs;
uint8_t *sub = strrchr(tmp, ' ');
int n_endchrs = 1; /* 1 = append space to end of match, 2 = append ": " */
if (!sub++) {
sub = tmp;
if (sub[0] != '/') /* make sure it's not a command */
n_endchrs = 2;
n_endchrs = sub[0] == '/' ? 0 : 2; /* no end chars if command */
}
if (string_is_empty(sub))
return -1;
switch(n_endchrs) {
case 0:
endchrs = "";
break;
case 1:
endchrs = " ";
break;
case 2:
endchrs = ": ";
break;
}
int s_len = strlen(sub);
const uint8_t *match;
bool is_match = false;
@ -225,9 +237,8 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
return -1;
/* put match in correct spot in buf and append endchars (space or ": ") */
const uint8_t *endchrs = n_endchrs == 1 ? " " : ": ";
int m_len = strlen(match);
int strt = (int) * pos - s_len;
int strt = *pos - s_len;
int diff = m_len - s_len + n_endchrs;
if (*len + diff > MAX_STR_SIZE)

View File

@ -435,7 +435,7 @@ void refresh_inactive_windows(void)
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
ToxWindow *a = &windows[i];
if (a->active && a != active_window && !a->is_prompt) /* if prompt doesn't have scroll mode */
if (a->active && a != active_window && (a->is_chat || a->is_groupchat))
line_info_print(a);
}
}