示例#1
0
static bool
open_input_source (ply_renderer_backend_t      *backend,
                   ply_renderer_input_source_t *input_source)
{
  int terminal_fd;

  assert (backend != NULL);
  assert (has_input_source (backend, input_source));

  terminal_fd = ply_terminal_get_fd (backend->terminal);

  input_source->backend = backend;
  input_source->terminal_input_watch = ply_event_loop_watch_fd (backend->loop, terminal_fd, PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
                                                                (ply_event_handler_t) on_key_event,
                                                                (ply_event_handler_t)
                                                                on_input_source_disconnected, input_source);
  return true;
}
示例#2
0
void
ply_text_display_write (ply_text_display_t *display,
                        const char         *format,
                        ...)
{
        int fd;

        va_list args;
        char *string;

        assert (display != NULL);
        assert (format != NULL);

        fd = ply_terminal_get_fd (display->terminal);

        string = NULL;
        va_start (args, format);
        vasprintf (&string, format, args);
        va_end (args);

        write (fd, string, strlen (string));
        free (string);
}