void TEPty::setWriteable(bool writeable) { struct stat sbuf; stat(pty()->ttyName(), &sbuf); if(writeable) chmod(pty()->ttyName(), sbuf.st_mode | S_IWGRP); else chmod(pty()->ttyName(), sbuf.st_mode & ~(S_IWGRP | S_IWOTH)); }
static Value * _pow(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; switch(expr->eval_type) { case T_INT: value_set_int(rval, pow(NATIVE_NUMBER(v1), NATIVE_NUMBER(v2))); break; case T_FLOAT: value_set_float(rval, powf(NATIVE_NUMBER(v1), NATIVE_NUMBER(v2))); break; default: pty(expr->eval_type); assert(false); } value_free(v2); return rval; }
static Value * _add(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; switch(expr->eval_type) { case T_INT: value_set_int(rval, NATIVE_NUMBER(v1) + NATIVE_NUMBER(v2)); break; case T_FLOAT: value_set_float(rval, NATIVE_NUMBER(v1) + NATIVE_NUMBER(v2)); break; case T_STRING: // TODO String concat? default: pty(expr->eval_type); assert(false); } value_free(v2); return rval; }
void TEPty::setErase(char erase) { struct termios tios; int fd = pty()->slaveFd(); if(tcgetattr(fd, &tios)) { qWarning("Uh oh.. can't get terminal attributes.."); return; } tios.c_cc[VERASE] = erase; if(tcsetattr(fd, TCSANOW, &tios)) qWarning("Uh oh.. can't set terminal attributes.."); }
static Value * _mod(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; switch(expr->eval_type) { case T_INT: value_set_int(rval, v1->as_int % v2->as_int); break; default: pty(expr->eval_type); assert(false); } value_free(v2); return rval; }
void TEPty::setSize(int lines, int cols) { pty()->setWinSize(lines, cols); }
void TEPty::useUtf8(bool on) { pty()->setUtf8Mode(on); }
void TEPty::setXonXoff(bool on) { pty()->setXonXoff(on); }