diff options
author | ache <ache@ache.one> | 2019-01-21 05:43:25 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2019-01-21 05:43:25 +0100 |
commit | 64bc1ee1851a7846590107a3ea86893a137f1be8 (patch) | |
tree | b608fc843bdb3a1251706abe05632d1de46b3f6d | |
parent | What was that ? (diff) |
Edit instead of remplace
-rwxr-xr-x | main.c | 78 | ||||
-rw-r--r-- | readline.c | 9 | ||||
-rw-r--r-- | readline.h | 2 | ||||
-rw-r--r-- | readline.o | bin | 0 -> 7384 bytes | |||
-rw-r--r-- | wind.c | 2 |
5 files changed, 49 insertions, 42 deletions
@@ -55,15 +55,15 @@ void fail_exit(const char *msg) { } -void edit_rl(menuC* menu,void func(TagLib_Tag *, const char*), int c); +void edit_rl(menuC* menu,void func(TagLib_Tag *, const char*), int c, const char* str); -void edit_rl(menuC* menu,void func(TagLib_Tag *, const char*), int c) { +void edit_rl(menuC* menu,void func(TagLib_Tag *, const char*), int c, const char* str) { status[1]=c; printStatus(); refresh(); curs_set(2); move(LINES-1, 0); - readline_n(); + readline_n(str); clear(); curs_set(0); itemC* it = menu->list+menu->hl; @@ -87,13 +87,15 @@ void edit_rl(menuC* menu,void func(TagLib_Tag *, const char*), int c) { } } } -void edit_rl_int(menuC* menu,void func(TagLib_Tag *, unsigned int), int c) { +void edit_rl_int(menuC* menu,void func(TagLib_Tag *, unsigned int), int c, int oldOne_int) { status[1]=c; printStatus(); refresh(); curs_set(2); move(LINES-1, 0); - readline_n(); + char oldOne[5]; + sprintf(oldOne, "%d", oldOne_int); + readline_n(oldOne); clear(); curs_set(0); itemC* it = menu->list+menu->hl; @@ -293,41 +295,43 @@ int main(int argc, char* argv[]){ // fprintf(stderr, "[%c]", c); } break; - case 'e': + case 'e': { echo(); move(LINES-1,1); - switch(c) { - case 't': - edit_rl(&menu,taglib_tag_set_title,'t'); - break; - case 'a': - edit_rl(&menu,taglib_tag_set_artist,'a'); - break; - case 'b': - edit_rl(&menu,taglib_tag_set_album,'b'); - break; - case 'y': - edit_rl_int(&menu,taglib_tag_set_year,'b'); - break; - case 'n': - edit_rl_int(&menu,taglib_tag_set_track,'b'); - break; - case 'g': - edit_rl(&menu,taglib_tag_set_genre,'g'); - break; - case 'c': - edit_rl(&menu,taglib_tag_set_comment,'c'); - break; - default: - ; - } - comp = 0; - status[0] = status[1] = 0; + itemC* it = menu.list+menu.hl; + switch(c) { + case 't': + edit_rl(&menu,taglib_tag_set_title,'t', taglib_tag_title(it->info.tag)); + break; + case 'a': + edit_rl(&menu,taglib_tag_set_artist,'a', taglib_tag_artist(it->info.tag)); + break; + case 'b': + edit_rl(&menu,taglib_tag_set_album,'b', taglib_tag_album(it->info.tag)); + break; + case 'y': + edit_rl_int(&menu,taglib_tag_set_year,'y', taglib_tag_year(it->info.tag)); + break; + case 'n': + edit_rl_int(&menu,taglib_tag_set_track,'n', taglib_tag_track(it->info.tag)); + break; + case 'g': + edit_rl(&menu,taglib_tag_set_genre,'g', taglib_tag_genre(it->info.tag)); + break; + case 'c': + edit_rl(&menu,taglib_tag_set_comment,'c', taglib_tag_comment(it->info.tag)); + break; + default: + ; + } + comp = 0; + status[0] = status[1] = 0; - printmenu(&menu); - printTagInfoHeader(); - printTagInfo(&menu); - break; + printmenu(&menu); + printTagInfoHeader(); + printTagInfo(&menu); + } + break; } printStatus(); printmenu(&menu); @@ -172,9 +172,14 @@ void init_readline(void) } -void readline_n(void) { +void readline_n(const char* str) { curs_set(2); resize(); + for( ; *str ; str++ ) { + if( *str != '\n' && *str != '\f' && *str != KEY_RESIZE ) { + forward_to_readline(*str); + } + } while (!should_exit) { // Using getch() here instead would refresh stdscr, overwriting the // initial contents of the other windows on startup @@ -197,5 +202,3 @@ void readline_n(void) { should_exit = 0; } - - @@ -15,7 +15,7 @@ -void readline_n(void); +void readline_n(const char*); void init_readline(void); diff --git a/readline.o b/readline.o Binary files differnew file mode 100644 index 0000000..932a9cc --- /dev/null +++ b/readline.o @@ -19,7 +19,7 @@ void prepare(char* s) { refresh(); strcpy(status, s); printStatus(); - readline_n(); + readline_n(""); clear(); curs_set(0); } |