Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e866806 in mainline for uspace/app/edit/edit.c


Ignore:
Timestamp:
2009-11-30T20:07:07Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
4a2aa91, 8b5001b
Parents:
1df977c (diff), b67c7d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge editor fix and string function improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    r1df977c re866806  
    102102#define ED_INFTY 65536
    103103
     104/** Maximum filename length that can be entered. */
     105#define INFNAME_MAX_LEN 128
     106
    104107static void key_handle_unmod(console_event_t const *ev);
    105108static void key_handle_ctrl(console_event_t const *ev);
     
    331334}
    332335
    333 #define INPUT_MAX_LEN 64
    334 
    335336/** Ask for a file name. */
    336337static char *filename_prompt(char const *prompt, char const *init_value)
     
    338339        console_event_t ev;
    339340        char *str;
    340         wchar_t buffer[INPUT_MAX_LEN + 1];
     341        wchar_t buffer[INFNAME_MAX_LEN + 1];
     342        int max_len;
    341343        int nc;
    342344        bool done;
     
    349351        console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0);
    350352
    351         str_to_wstr(buffer, INPUT_MAX_LEN + 1, init_value);
     353        max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt));
     354        str_to_wstr(buffer, max_len + 1, init_value);
    352355        nc = wstr_length(buffer);
    353356        done = false;
     
    376379                                        break;
    377380                                default:
    378                                         if (ev.c >= 32 && nc < INPUT_MAX_LEN) {
     381                                        if (ev.c >= 32 && nc < max_len) {
    379382                                                putchar(ev.c);
    380383                                                fflush(stdout);
     
    388391
    389392        buffer[nc] = '\0';
    390 
    391         str = malloc(STR_BOUNDS(wstr_length(buffer)) + 1);
    392         if (str == NULL)
    393                 return NULL;
    394 
    395         wstr_nstr(str, buffer, STR_BOUNDS(wstr_length(buffer)) + 1);
     393        str = wstr_to_astr(buffer);
    396394
    397395        console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0);
Note: See TracChangeset for help on using the changeset viewer.