mirror of
https://github.com/Tha14/toxic.git
synced 2025-04-14 11:42:58 +02:00
no trailing space for command tab-complete
This commit is contained in:
parent
4d249c5fe3
commit
f9e15cd60b
@ -212,7 +212,7 @@ static int nodelist_load(char *filename)
|
|||||||
if (name == NULL || port == NULL || key_ascii == NULL)
|
if (name == NULL || port == NULL || key_ascii == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
strncpy(nodes[linecnt], name, NODELEN);
|
snprintf(nodes[linecnt], sizeof(nodes[linecnt]), "%s", name);
|
||||||
nodes[linecnt][NODELEN - 1] = 0;
|
nodes[linecnt][NODELEN - 1] = 0;
|
||||||
ports[linecnt] = htons(atoi(port));
|
ports[linecnt] = htons(atoi(port));
|
||||||
|
|
||||||
|
@ -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];
|
uint8_t tmp[MAX_STR_SIZE];
|
||||||
snprintf(tmp, sizeof(tmp), "%s", ubuf);
|
snprintf(tmp, sizeof(tmp), "%s", ubuf);
|
||||||
tmp[*pos] = '\0';
|
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, ' ');
|
uint8_t *sub = strrchr(tmp, ' ');
|
||||||
int n_endchrs = 1; /* 1 = append space to end of match, 2 = append ": " */
|
|
||||||
|
|
||||||
if (!sub++) {
|
if (!sub++) {
|
||||||
sub = tmp;
|
sub = tmp;
|
||||||
|
n_endchrs = sub[0] == '/' ? 0 : 2; /* no end chars if command */
|
||||||
if (sub[0] != '/') /* make sure it's not a command */
|
|
||||||
n_endchrs = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string_is_empty(sub))
|
if (string_is_empty(sub))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
switch(n_endchrs) {
|
||||||
|
case 0:
|
||||||
|
endchrs = "";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
endchrs = " ";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
endchrs = ": ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int s_len = strlen(sub);
|
int s_len = strlen(sub);
|
||||||
const uint8_t *match;
|
const uint8_t *match;
|
||||||
bool is_match = false;
|
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;
|
return -1;
|
||||||
|
|
||||||
/* put match in correct spot in buf and append endchars (space or ": ") */
|
/* 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 m_len = strlen(match);
|
||||||
int strt = (int) * pos - s_len;
|
int strt = *pos - s_len;
|
||||||
int diff = m_len - s_len + n_endchrs;
|
int diff = m_len - s_len + n_endchrs;
|
||||||
|
|
||||||
if (*len + diff > MAX_STR_SIZE)
|
if (*len + diff > MAX_STR_SIZE)
|
||||||
|
@ -435,7 +435,7 @@ void refresh_inactive_windows(void)
|
|||||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||||
ToxWindow *a = &windows[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);
|
line_info_print(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user