Changeset 79ae36dd in mainline for uspace/app/edit/edit.c


Ignore:
Timestamp:
2011-06-08T19:01:55Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

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

    r764d71e r79ae36dd  
    9494} doc_t;
    9595
    96 static int con;
     96static console_ctrl_t *con;
    9797static doc_t doc;
    9898static bool done;
     
    115115static void cursor_setvis(bool visible);
    116116
    117 static void key_handle_unmod(console_event_t const *ev);
    118 static void key_handle_ctrl(console_event_t const *ev);
    119 static void key_handle_shift(console_event_t const *ev);
     117static void key_handle_unmod(kbd_event_t const *ev);
     118static void key_handle_ctrl(kbd_event_t const *ev);
     119static void key_handle_shift(kbd_event_t const *ev);
    120120static void key_handle_movement(unsigned int key, bool shift);
    121121
     
    158158int main(int argc, char *argv[])
    159159{
    160         console_event_t ev;
     160        kbd_event_t ev;
    161161        coord_t coord;
    162162        bool new_file;
     
    164164        spt_t pt;
    165165
    166         con = fphone(stdout);
     166        con = console_init(stdin, stdout);
    167167        console_clear(con);
    168168
     
    219219
    220220        while (!done) {
    221                 console_get_event(con, &ev);
     221                console_get_kbd_event(con, &ev);
    222222                pane.rflags = 0;
    223223
     
    277277
    278278/** Handle key without modifier. */
    279 static void key_handle_unmod(console_event_t const *ev)
     279static void key_handle_unmod(kbd_event_t const *ev)
    280280{
    281281        switch (ev->key) {
     
    320320
    321321/** Handle Shift-key combination. */
    322 static void key_handle_shift(console_event_t const *ev)
     322static void key_handle_shift(kbd_event_t const *ev)
    323323{
    324324        switch (ev->key) {
     
    344344
    345345/** Handle Ctrl-key combination. */
    346 static void key_handle_ctrl(console_event_t const *ev)
     346static void key_handle_ctrl(kbd_event_t const *ev)
    347347{
    348348        switch (ev->key) {
     
    497497static char *filename_prompt(char const *prompt, char const *init_value)
    498498{
    499         console_event_t ev;
     499        kbd_event_t ev;
    500500        char *str;
    501501        wchar_t buffer[INFNAME_MAX_LEN + 1];
     
    517517
    518518        while (!done) {
    519                 console_get_event(con, &ev);
     519                console_get_kbd_event(con, &ev);
    520520
    521521                if (ev.type == KEY_PRESS) {
     
    531531                                        if (nc > 0) {
    532532                                                putchar('\b');
    533                                                 fflush(stdout);
     533                                                console_flush(con);
    534534                                                --nc;
    535535                                        }
     
    541541                                        if (ev.c >= 32 && nc < max_len) {
    542542                                                putchar(ev.c);
    543                                                 fflush(stdout);
     543                                                console_flush(con);
    544544                                                buffer[nc++] = ev.c;
    545545                                        }
     
    689689                for (j = 0; j < scr_columns; ++j)
    690690                        putchar(' ');
    691                 fflush(stdout);
     691                console_flush(con);
    692692        }
    693693
     
    757757                if (coord_cmp(&csel_start, &rbc) <= 0 &&
    758758                    coord_cmp(&rbc, &csel_end) < 0) {
    759                         fflush(stdout);
     759                        console_flush(con);
    760760                        console_set_style(con, STYLE_SELECTED);
    761                         fflush(stdout);
     761                        console_flush(con);
    762762                }
    763763
     
    768768                while (pos < size) {
    769769                        if ((csel_start.row == rbc.row) && (csel_start.column == s_column)) {
    770                                 fflush(stdout);
     770                                console_flush(con);
    771771                                console_set_style(con, STYLE_SELECTED);
    772                                 fflush(stdout);
     772                                console_flush(con);
    773773                        }
    774774       
    775775                        if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) {
    776                                 fflush(stdout);
     776                                console_flush(con);
    777777                                console_set_style(con, STYLE_NORMAL);
    778                                 fflush(stdout);
     778                                console_flush(con);
    779779                        }
    780780       
     
    794794
    795795                if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) {
    796                         fflush(stdout);
     796                        console_flush(con);
    797797                        console_set_style(con, STYLE_NORMAL);
    798                         fflush(stdout);
     798                        console_flush(con);
    799799                }
    800800
     
    808808                for (j = 0; j < fill; ++j)
    809809                        putchar(' ');
    810                 fflush(stdout);
     810                console_flush(con);
    811811                console_set_style(con, STYLE_NORMAL);
    812812        }
     
    833833        int pos = scr_columns - 1 - n;
    834834        printf("%*s", pos, "");
    835         fflush(stdout);
     835        console_flush(con);
    836836        console_set_style(con, STYLE_NORMAL);
    837837
     
    11581158        int pos = -(scr_columns - 3);
    11591159        printf(" %*s ", pos, str);
    1160         fflush(stdout);
     1160        console_flush(con);
    11611161        console_set_style(con, STYLE_NORMAL);
    11621162
Note: See TracChangeset for help on using the changeset viewer.