consoled-terminal.c revision dc75168823540076b354135f6e2de7a9a978fbca
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "consoled.h"
#include "list.h"
#include "macro.h"
#include "util.h"
int r;
if (t->pty) {
if (r < 0)
return log_oom();
}
return 0;
}
static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const void *ptr, size_t size) {
int r;
switch (event) {
case PTY_CHILD:
log_debug("PTY child exited");
break;
case PTY_DATA:
if (r < 0)
log_error_errno(r, "Cannot update screen state: %m");
workspace_dirty(t->workspace);
break;
}
return 0;
}
int r;
assert(w);
if (!t)
return -ENOMEM;
t->workspace = w;
r = term_parser_new(&t->parser, true);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (out)
*out = t;
t = NULL;
return 0;
}
if (!t)
return NULL;
if (t->pty) {
}
term_screen_unref(t->screen);
term_parser_free(t->parser);
free(t);
return NULL;
}
void terminal_resize(Terminal *t) {
int r;
assert(t);
if (t->pty) {
if (r < 0)
log_error_errno(r, "Cannot resize pty: %m");
}
if (r < 0)
log_error_errno(r, "Cannot resize screen: %m");
}
void terminal_run(Terminal *t) {
assert(t);
if (t->pty)
return;
t,
term_screen_get_height(t->screen));
if (pid < 0) {
return;
} else if (pid == 0) {
/* child */
char **argv = (char*[]){
};
_exit(1);
}
}
int r;
TERM_KBDMOD_IDX_CTRL == (int)IDEV_KBDMOD_IDX_CTRL &&
TERM_KBDMOD_IDX_ALT == (int)IDEV_KBDMOD_IDX_ALT &&
TERM_KBDMOD_IDX_LINUX == (int)IDEV_KBDMOD_IDX_LINUX &&
TERM_KBDMOD_IDX_CAPS == (int)IDEV_KBDMOD_IDX_CAPS);
r = term_screen_feed_keyboard(t->screen,
if (r < 0)
log_error_errno(r, "Cannot feed keyboard data to screen: %m");
}
}
case IDEV_DATA_KEYBOARD:
break;
}
}
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i)
}
}
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i) {
else
++px;
}
src += src_stride;
dst += dst_stride;
}
}
typedef struct {
const grdev_display_target *target;
bool dirty;
void *userdata,
unsigned int x,
unsigned int y,
unsigned int ch_width) {
int r;
if (n_ch > 0) {
if (r < 0)
if (r < 0)
unifont_fallback(&g);
}
return 0;
if (n_ch < 1) {
bg);
} else {
bg);
bg);
g.data,
g.stride,
fg,
bg);
}
return 0;
}
TerminalDrawContext ctx = { };
assert(t);
/* start up terminal on first frame */
terminal_run(t);
/* if the frontbuffer is new enough, no reason to redraw */
return false;
} else {
/* force flip if no frontbuffer is set, yet */
}
}