mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:13:26 +01:00
sort directories and skip special symbols for path autocomplete
This commit is contained in:
parent
8660047ec1
commit
8d8df585ad
@ -273,7 +273,8 @@ int dir_match(ToxWindow *self, Tox *m, wchar_t *line)
|
|||||||
int dircount = 0;
|
int dircount = 0;
|
||||||
|
|
||||||
while ((entry = readdir(dp)) && dircount < MAX_DIRS) {
|
while ((entry = readdir(dp)) && dircount < MAX_DIRS) {
|
||||||
if (strncmp(entry->d_name, b_name, b_name_len) == 0) {
|
if (strncmp(entry->d_name, b_name, b_name_len) == 0
|
||||||
|
&& strcmp(".", entry->d_name) && strcmp("..", entry->d_name)) {
|
||||||
snprintf(dirnames[dircount], sizeof(dirnames[dircount]), "%s", entry->d_name);
|
snprintf(dirnames[dircount], sizeof(dirnames[dircount]), "%s", entry->d_name);
|
||||||
++dircount;
|
++dircount;
|
||||||
}
|
}
|
||||||
@ -282,8 +283,10 @@ int dir_match(ToxWindow *self, Tox *m, wchar_t *line)
|
|||||||
if (dircount == 0)
|
if (dircount == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (dircount > 1)
|
if (dircount > 1) {
|
||||||
|
qsort(dirnames, dircount, NAME_MAX, qsort_strcasecmp_hlpr);
|
||||||
print_matches(self, m, dirnames, dircount, NAME_MAX);
|
print_matches(self, m, dirnames, dircount, NAME_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
return complete_line(self, dirnames, dircount, NAME_MAX);
|
return complete_line(self, dirnames, dircount, NAME_MAX);
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ int wcs_to_mbs_buf(char *buf, const wchar_t *string, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* case-insensitive string compare function for use with qsort */
|
/* case-insensitive string compare function for use with qsort */
|
||||||
int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2)
|
int qsort_strcasecmp_hlpr(const void *str1, const void *str2)
|
||||||
{
|
{
|
||||||
return strcasecmp((const char *) nick1, (const char *) nick2);
|
return strcasecmp((const char *) str1, (const char *) str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 1 if nick is valid, 0 if not. A valid toxic nick:
|
/* Returns 1 if nick is valid, 0 if not. A valid toxic nick:
|
||||||
|
@ -70,7 +70,7 @@ int timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);
|
|||||||
void alert_window(ToxWindow *self, int type, bool is_beep);
|
void alert_window(ToxWindow *self, int type, bool is_beep);
|
||||||
|
|
||||||
/* case-insensitive string compare function for use with qsort */
|
/* case-insensitive string compare function for use with qsort */
|
||||||
int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2);
|
int qsort_strcasecmp_hlpr(const void *str1, const void *str2);
|
||||||
|
|
||||||
/* Returns 1 if nick is valid, 0 if not. A valid toxic nick:
|
/* Returns 1 if nick is valid, 0 if not. A valid toxic nick:
|
||||||
- cannot be empty
|
- cannot be empty
|
||||||
|
Loading…
Reference in New Issue
Block a user