Added Unicode-Support

This commit is contained in:
Axel Wagner
2010-08-06 03:32:05 +02:00
parent 7d7867acce
commit 1daa395a77
12 changed files with 352 additions and 141 deletions

View File

@ -81,7 +81,7 @@ void child_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
strip_dzen_formats(buffer);
FREE(statusline);
statusline = buffer;
printf("%s", buffer);
printf("%s\n", buffer);
draw_bars();
}
@ -91,45 +91,52 @@ void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) {
}
void start_child(char *command) {
int fd[2];
pipe(fd);
child_pid = fork();
switch (child_pid) {
case -1:
printf("ERROR: Couldn't fork()");
exit(EXIT_FAILURE);
case 0:
close(fd[0]);
child_pid = 0;
if (command != NULL) {
int fd[2];
pipe(fd);
child_pid = fork();
switch (child_pid) {
case -1:
printf("ERROR: Couldn't fork()");
exit(EXIT_FAILURE);
case 0:
close(fd[0]);
dup2(fd[1], STDOUT_FILENO);
dup2(fd[1], STDOUT_FILENO);
static const char *shell = NULL;
static const char *shell = NULL;
if ((shell = getenv("SHELL")) == NULL)
shell = "/bin/sh";
if ((shell = getenv("SHELL")) == NULL)
shell = "/bin/sh";
execl(shell, shell, "-c", command, (char*) NULL);
break;
default:
close(fd[1]);
execl(shell, shell, "-c", command, (char*) NULL);
return;
default:
close(fd[1]);
dup2(fd[0], STDIN_FILENO);
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
dup2(fd[0], STDIN_FILENO);
child_io = malloc(sizeof(ev_io));
ev_io_init(child_io, &child_io_cb, STDIN_FILENO, EV_READ);
ev_io_start(main_loop, child_io);
/* We must cleanup, if the child unexpectedly terminates */
child_sig = malloc(sizeof(ev_io));
ev_child_init(child_sig, &child_sig_cb, child_pid, 0);
ev_child_start(main_loop, child_sig);
break;
break;
}
}
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
child_io = malloc(sizeof(ev_io));
ev_io_init(child_io, &child_io_cb, STDIN_FILENO, EV_READ);
ev_io_start(main_loop, child_io);
/* We must cleanup, if the child unexpectedly terminates */
child_sig = malloc(sizeof(ev_io));
ev_child_init(child_sig, &child_sig_cb, child_pid, 0);
ev_child_start(main_loop, child_sig);
}
void kill_child() {
kill(child_pid, SIGQUIT);
if (child_pid != 0) {
kill(child_pid, SIGQUIT);
}
cleanup();
}