Changeset 178d6a3 in mainline for uspace/srv/hid/remcons/remcons.c


Ignore:
Timestamp:
2012-01-12T11:03:17Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
03e0a244
Parents:
c17c4e28
Message:

remcons: handle backspace

The handling is a bit hackish because the server pretends that it remembers
X cursor position and sends BS manually when they differ (with the new one)
by minus one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/remcons/remcons.c

    rc17c4e28 r178d6a3  
    112112                        break;
    113113                case CONSOLE_GET_POS:
    114                         async_answer_2(callid, EOK, 0, 0);
     114                        fibril_mutex_lock(&user->guard);
     115                        async_answer_2(callid, EOK, user->cursor_x, 0);
     116                        fibril_mutex_unlock(&user->guard);
    115117                        break;
    116118                case CONSOLE_GET_EVENT: {
     
    125127                        break;
    126128                }
    127                 case CONSOLE_GOTO:
    128                         async_answer_0(callid, ENOTSUP);
    129                         break;
     129                case CONSOLE_GOTO: {
     130                        int new_x = IPC_GET_ARG1(call);
     131                        telnet_user_update_cursor_x(user, new_x);
     132                        async_answer_0(callid, ENOTSUP);
     133                        break;
     134                }
    130135                case VFS_OUT_READ:
    131136                        async_answer_0(callid, ENOTSUP);
    132137                        break;
    133138                case VFS_OUT_WRITE: {
    134                         char *buf;
    135                         char *buf_converted;
     139                        uint8_t *buf;
    136140                        size_t size;
    137141                        int rc = async_data_write_accept((void **)&buf, false, 0, 0, 0, &size);
     
    141145                                break;
    142146                        }
    143                         buf_converted = malloc(2 * size + 1);
    144                         assert(buf_converted);
    145                         int buf_converted_size = 0;
    146                         /* Convert new-lines. */
    147                         for (size_t i = 0; i < size; i++) {
    148                                 if (buf[i] == 10) {
    149                                         buf_converted[buf_converted_size++] = 13;
    150                                         buf_converted[buf_converted_size++] = 10;
    151                                 } else {
    152                                         buf_converted[buf_converted_size++] = buf[i];
    153                                 }
    154                         }
    155                         /* Add terminating zero for printing purposes. */
    156                         buf_converted[buf_converted_size] = 0;
    157 
    158                         fibril_mutex_lock(&user->guard);
    159                         rc = send(user->socket, buf_converted, buf_converted_size, 0);
    160                         fibril_mutex_unlock(&user->guard);
     147
     148                        rc = telnet_user_send_data(user, buf, size);
    161149                        free(buf);
    162150
Note: See TracChangeset for help on using the changeset viewer.