- if(current_text[0] == '/' ||
- current_text[0] == '~')
- {
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
- char string[BCTEXTLEN];
- strncpy(string, current_text, sizeof(string));
- char *ptr = strrchr(string, '/');
- if(!ptr) ptr = strrchr(string, '~');
-
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
- *(ptr + 1) = 0;
- int suggestion_column = ptr + 1 - string;
-
- fs.set_filter(get_resources()->filebox_filter);
-// fs.set_sort_order(filebox->sort_order);
-// fs.set_sort_field(filebox->column_type[filebox->sort_column]);
-
-
-//printf("BC_TextBox::calculate_suggestions %d %c %s\n", __LINE__, *ptr, string);
- if(current_text[0] == '~' && *ptr != '/')
- {
- fs.update("/home");
- }
- else
- {
- fs.parse_tildas(string);
- fs.update(string);
- }
-//printf("BC_TextBox::calculate_suggestions %d %d\n", __LINE__, fs.total_files());
-
-
-// Accept only entries with matching trailing characters
- ptr = strrchr((char*)current_text, '/');
- if(!ptr) ptr = strrchr((char*)current_text, '~');
- if(ptr) ptr++;
-//printf("BC_TextBox::calculate_suggestions %d %s %p\n", __LINE__, current_text, ptr);
-
-
- if(ptr && *ptr)
- {
- for(int i = 0; i < fs.total_files(); i++)
- {
- char *current_name = fs.get_entry(i)->name;
- if(!strncmp(ptr, current_name, strlen(ptr)))
- {
- suggestions.append(current_name);
- //printf("BC_TextBox::calculate_suggestions %d %s\n", __LINE__, current_name);
- }
- }
- }
- else
- // Accept all entries
- for(int i = 0; i < fs.total_files(); i++)
- {
- //printf("BC_TextBox::calculate_suggestions %d %s\n", __LINE__, fs.get_entry(i)->name);
- suggestions.append(fs.get_entry(i)->name);
+ if( dirname[0] ) {
+ if( filter ) fs.set_filter(filter);
+ char *prefix, *cp;
+ strncpy(dirname, current_text, sizeof(dirname));
+ if( (cp=strrchr(dirname, '/')) ||
+ (cp=strrchr(dirname, '~')) ) *++cp = 0;
+ fs.parse_tildas(dirname);
+ fs.update(dirname);
+ cp = (char *)current_text;
+ if( (prefix=strrchr(cp, '/')) ||
+ (prefix=strrchr(cp, '~')) ) ++prefix;
+ suggestion_column = !prefix ? 0 : prefix - cp;
+ int prefix_len = prefix ? strlen(prefix) : 0;
+// only include items where the filename matches the basename prefix
+ for(int i = 0; i < fs.total_files(); i++) {
+ char *current_name = fs.get_entry(i)->name;
+ if( prefix_len>0 && strncmp(prefix, current_name, prefix_len) ) continue;
+ suggestions.append(current_name);