archive: file extension removed in rename menu (#511)
Co-authored-by: SG <who.just.the.doctor@gmail.com>
This commit is contained in:
		
							parent
							
								
									5fc533385b
								
							
						
					
					
						commit
						216f8b4fb8
					
				| @ -238,6 +238,15 @@ static void archive_text_input_callback(void* context, char* text) { | ||||
|     string_cat(buffer_src, archive->browser.name); | ||||
|     string_cat_str(buffer_dst, text); | ||||
| 
 | ||||
|     // append extension
 | ||||
|     ArchiveViewModel* model = view_get_model(archive->view_archive_main); | ||||
|     ArchiveFile_t* file = | ||||
|         files_array_get(model->files, CLAMP(model->idx, files_array_size(model->files) - 1, 0)); | ||||
|     string_cat(buffer_src, known_ext[file->type]); | ||||
|     string_cat(buffer_dst, known_ext[file->type]); | ||||
|     model = NULL; | ||||
|     file = NULL; | ||||
| 
 | ||||
|     common_api->rename(string_get_cstr(buffer_src), string_get_cstr(buffer_dst)); | ||||
| 
 | ||||
|     view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewMain); | ||||
| @ -252,6 +261,8 @@ static void archive_enter_text_input(ArchiveApp* archive) { | ||||
| 
 | ||||
|     string_set(archive->browser.text_input_buffer, archive->browser.name); | ||||
| 
 | ||||
|     archive_trim_file_ext(archive->browser.text_input_buffer); | ||||
| 
 | ||||
|     char* text_input_buffer_ptr = stringi_get_cstr(archive->browser.text_input_buffer); | ||||
| 
 | ||||
|     text_input_set_header_text(archive->text_input, "Rename:"); | ||||
|  | ||||
| @ -47,7 +47,7 @@ static void render_item_menu(Canvas* canvas, ArchiveViewModel* model) { | ||||
|     canvas_draw_icon_name(canvas, 64, 20 + model->menu_idx * 11, I_ButtonRight_4x7); | ||||
| } | ||||
| 
 | ||||
| static void trim_file_ext(string_t name) { | ||||
| void archive_trim_file_ext(string_t name) { | ||||
|     size_t str_len = strlen(string_get_cstr(name)); | ||||
|     char* buff_ptr = stringi_get_cstr(name); | ||||
|     char* end = buff_ptr + str_len; | ||||
| @ -88,7 +88,7 @@ static void draw_list(Canvas* canvas, ArchiveViewModel* model) { | ||||
| 
 | ||||
|         string_set(str_buff, file->name); | ||||
| 
 | ||||
|         if(is_known_app(file->type)) trim_file_ext(str_buff); | ||||
|         if(is_known_app(file->type)) archive_trim_file_ext(str_buff); | ||||
|         elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX); | ||||
| 
 | ||||
|         if(model->idx == idx) { | ||||
|  | ||||
| @ -63,3 +63,4 @@ typedef struct { | ||||
| } ArchiveViewModel; | ||||
| 
 | ||||
| void archive_view_render(Canvas* canvas, void* model); | ||||
| void archive_trim_file_ext(string_t name); | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 its your bedtime
						its your bedtime