Changeset b48e680f in mainline for uspace/lib/c


Ignore:
Timestamp:
2021-11-03T10:23:28Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ec8a1bf
Parents:
ce862ac
git-author:
Jiri Svoboda <jiri@…> (2021-11-02 19:19:50)
git-committer:
Jiri Svoboda <jiri@…> (2021-11-03 10:23:28)
Message:

Allow console application to set the terminal window caption

Location:
uspace/lib/c
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/con_srv.c

    rce862ac rb48e680f  
    281281}
    282282
     283static void con_set_caption_srv(con_srv_t *srv, ipc_call_t *icall)
     284{
     285        char *caption;
     286        errno_t rc;
     287
     288        rc = async_data_write_accept((void **) &caption, true, 0,
     289            CON_CAPTION_MAXLEN, 0, NULL);
     290        if (rc != EOK) {
     291                async_answer_0(icall, rc);
     292                return;
     293        }
     294
     295        if (srv->srvs->ops->set_caption == NULL) {
     296                async_answer_0(icall, ENOTSUP);
     297                return;
     298        }
     299
     300        srv->srvs->ops->set_caption(srv, caption);
     301        free(caption);
     302        async_answer_0(icall, EOK);
     303}
     304
    283305static void con_get_event_srv(con_srv_t *srv, ipc_call_t *icall)
    284306{
     
    488510                        con_set_cursor_visibility_srv(srv, &call);
    489511                        break;
     512                case CONSOLE_SET_CAPTION:
     513                        con_set_caption_srv(srv, &call);
     514                        break;
    490515                case CONSOLE_GET_EVENT:
    491516                        con_get_event_srv(srv, &call);
  • uspace/lib/c/generic/io/console.c

    rce862ac rb48e680f  
    4040#include <errno.h>
    4141#include <stdlib.h>
     42#include <str.h>
    4243#include <vfs/vfs_sess.h>
    4344#include <io/console.h>
     
    128129        async_req_1_0(exch, CONSOLE_SET_CURSOR_VISIBILITY, (show != false));
    129130        async_exchange_end(exch);
     131}
     132
     133/** Set console caption.
     134 *
     135 * Set caption text for the console (if the console suports captions).
     136 *
     137 * @param ctrl Console
     138 * @param caption Caption text
     139 * @return EOK on success or an error code
     140 */
     141errno_t console_set_caption(console_ctrl_t *ctrl, const char *caption)
     142{
     143        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
     144        ipc_call_t answer;
     145        aid_t req = async_send_0(exch, CONSOLE_SET_CAPTION, &answer);
     146        errno_t retval = async_data_write_start(exch, caption, str_size(caption));
     147
     148        if (retval != EOK) {
     149                async_forget(req);
     150                async_exchange_end(exch);
     151                return retval;
     152        }
     153
     154        async_wait_for(req, &retval);
     155        async_exchange_end(exch);
     156        return EOK;
    130157}
    131158
  • uspace/lib/c/include/io/con_srv.h

    rce862ac rb48e680f  
    5151typedef struct con_ops con_ops_t;
    5252
     53#define CON_CAPTION_MAXLEN 255
     54
    5355/** Service setup (per sevice) */
    5456typedef struct {
     
    8385        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8486        void (*set_cursor_visibility)(con_srv_t *, bool);
     87        errno_t (*set_caption)(con_srv_t *, const char *);
    8588        errno_t (*get_event)(con_srv_t *, cons_event_t *);
    8689        errno_t (*map)(con_srv_t *, sysarg_t, sysarg_t, charfield_t **);
  • uspace/lib/c/include/io/console.h

    rce862ac rb48e680f  
    8383
    8484extern void console_cursor_visibility(console_ctrl_t *, bool);
     85extern errno_t console_set_caption(console_ctrl_t *, const char *);
    8586extern errno_t console_get_color_cap(console_ctrl_t *, sysarg_t *);
    8687extern errno_t console_get_event(console_ctrl_t *, cons_event_t *);
  • uspace/lib/c/include/ipc/console.h

    rce862ac rb48e680f  
    5050        CONSOLE_SET_RGB_COLOR,
    5151        CONSOLE_SET_CURSOR_VISIBILITY,
     52        CONSOLE_SET_CAPTION,
    5253        CONSOLE_MAP,
    5354        CONSOLE_UNMAP,
Note: See TracChangeset for help on using the changeset viewer.