2016-10-18 11:21:50 -07:00
|
|
|
#include "private.h"
|
2019-12-05 10:58:25 -08:00
|
|
|
#include <errno.h>
|
2016-07-30 07:31:56 -07:00
|
|
|
#include <stdlib.h>
|
2019-12-05 10:58:25 -08:00
|
|
|
#include <unistd.h>
|
2016-07-30 07:31:56 -07:00
|
|
|
#include "tycommon.h"
|
|
|
|
|
|
|
|
|
2017-12-18 17:16:24 -08:00
|
|
|
int
|
2016-07-30 07:31:56 -07:00
|
|
|
is_running_in_terminology(void)
|
|
|
|
{
|
2017-12-18 17:16:24 -08:00
|
|
|
if (!getenv("TERMINOLOGY")) return 0;
|
2016-07-30 07:31:56 -07:00
|
|
|
// Terminology's escape codes do not got through tmux
|
2017-12-18 17:16:24 -08:00
|
|
|
if (getenv("TMUX")) return 0;
|
2016-07-30 07:31:56 -07:00
|
|
|
// Terminology's escape codes do not got through screen
|
2017-12-18 17:16:24 -08:00
|
|
|
if (getenv("STY")) return 0;
|
2016-07-30 07:31:56 -07:00
|
|
|
|
2017-12-18 17:16:24 -08:00
|
|
|
return 1;
|
2016-07-30 07:31:56 -07:00
|
|
|
}
|
2019-12-05 10:58:25 -08:00
|
|
|
|
|
|
|
ssize_t
|
|
|
|
ty_write(int fd, const void *buf, size_t count)
|
|
|
|
{
|
|
|
|
const char *data = buf;
|
|
|
|
ssize_t len = count;
|
|
|
|
|
|
|
|
while (len > 0)
|
|
|
|
{
|
|
|
|
ssize_t res = write(fd, data, len);
|
|
|
|
|
|
|
|
if (res < 0)
|
|
|
|
{
|
|
|
|
if (errno == EINTR || errno == EAGAIN)
|
|
|
|
continue;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
data += res;
|
|
|
|
len -= res;
|
|
|
|
}
|
2020-01-07 02:48:08 -08:00
|
|
|
return count;
|
2019-12-05 10:58:25 -08:00
|
|
|
}
|