예제 #1
0
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
	const struct mdoc_node	*n;
	const struct mdoc_meta	*m;
	struct termp		*p;

	p = (struct termp *)arg;

	p->overstep = 0;
	p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	if (NULL == p->symtab)
		switch (p->enc) {
		case (TERMENC_ASCII):
			p->symtab = chars_init(CHARS_ASCII);
			break;
		default:
			abort();
			/* NOTREACHED */
		}

	n = mdoc_node(mdoc);
	m = mdoc_meta(mdoc);

	term_begin(p, print_mdoc_head, print_mdoc_foot, m);

	if (n->child)
		print_mdoc_nodelist(p, NULL, m, n->child);

	term_end(p);
}
예제 #2
0
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
	const struct mdoc_node	*n;
	const struct mdoc_meta	*meta;
	struct termp		*p;

	p = (struct termp *)arg;

	if (0 == p->defindent)
		p->defindent = 5;

	p->overstep = 0;
	p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	if (NULL == p->symtab)
		p->symtab = mchars_alloc();

	n = mdoc_node(mdoc);
	meta = mdoc_meta(mdoc);

	term_begin(p, print_mdoc_head, print_mdoc_foot, meta);

	if (n->child)
		print_mdoc_nodelist(p, NULL, meta, n->child);

	term_end(p);
}
예제 #3
0
파일: main.c 프로젝트: fujii/myd-3.4-plus
void finish(int s) {
#ifdef USE_XSELECTION
    get_sel_end();
#endif
    term_end();
    myd_close(myd);
    exit(s);
}
예제 #4
0
/**
 * エラー表示し 終了する
 */
void term_error( char* message){

    term_gotoxy(0, 24);
    term_end();

    term_disp(message);
    kanji_out();

    exit(1);
}
예제 #5
0
void
terminal_man(void *arg, const struct man *man)
{
	struct termp		*p;
	const struct man_meta	*meta;
	struct man_node		*n;
	struct mtermp		 mt;

	p = (struct termp *)arg;

	p->overstep = 0;
	p->rmargin = p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	n = man_node(man)->child;
	meta = man_meta(man);

	memset(&mt, 0, sizeof(struct mtermp));

	mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
	mt.offset = term_len(p, p->defindent);
	mt.pardist = 1;

	if (p->synopsisonly) {
		while (n != NULL) {
			if (n->tok == MAN_SH &&
			    n->child->child->type == MAN_TEXT &&
			    !strcmp(n->child->child->string, "SYNOPSIS")) {
				if (n->child->next->child != NULL)
					print_man_nodelist(p, &mt,
					    n->child->next->child, meta);
				term_newln(p);
				break;
			}
			n = n->next;
		}
	} else {
		if (p->defindent == 0)
			p->defindent = 7;
		term_begin(p, print_man_head, print_man_foot, meta);
		p->flags |= TERMP_NOSPACE;
		if (n != NULL)
			print_man_nodelist(p, &mt, n, meta);
		term_end(p);
	}
}
예제 #6
0
unsigned char term_getkey_sub()
{
    unsigned char c;

	#ifdef UNIX
	#ifdef CURSES
    c = getch();
	#else
    c = getchar();
	#endif
	#endif
	#ifdef MSDOS
    c = getch();
	#endif
    
	if (c == CTRLC){
		term_end();
		exit(1);
	}
	
	if(c == ESC && esc_mode == FALSE){
		return term_esc_key();
	}

/*
	//上下左右キーの場合,このフィルターをする事で,ESCキーと解釈するのを防ぐ
	switch(c){
		case 0x41:	
			return CUR_UP;
		case 0x42:
			return CUR_DOWN;
		case 0x43:
			return CUR_RIGHT;
		case 0x44:				
			return CUR_LEFT;
		default:
			return c;
	}
*/
	return c;
}
예제 #7
0
void
terminal_man(void *arg, const struct man *man)
{
	struct termp		*p;
	const struct man_node	*n;
	const struct man_meta	*m;
	struct mtermp		 mt;

	p = (struct termp *)arg;

	p->overstep = 0;
	p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	if (NULL == p->symtab)
		switch (p->enc) {
		case (TERMENC_ASCII):
			p->symtab = chars_init(CHARS_ASCII);
			break;
		default:
			abort();
			/* NOTREACHED */
		}

	n = man_node(man);
	m = man_meta(man);

	term_begin(p, print_man_head, print_man_foot, m);
	p->flags |= TERMP_NOSPACE;

	mt.fl = 0;
	mt.lmargin = term_len(p, INDENT);
	mt.offset = term_len(p, INDENT);

	if (n->child)
		print_man_nodelist(p, &mt, n->child, m);

	term_end(p);
}
예제 #8
0
파일: mdoc_term.c 프로젝트: jashank/freebsd
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
	const struct mdoc_meta	*meta;
	struct mdoc_node	*n;
	struct termp		*p;

	p = (struct termp *)arg;

	p->overstep = 0;
	p->rmargin = p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	n = mdoc_node(mdoc)->child;
	meta = mdoc_meta(mdoc);

	if (p->synopsisonly) {
		while (n != NULL) {
			if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
				if (n->child->next->child != NULL)
					print_mdoc_nodelist(p, NULL,
					    meta, n->child->next->child);
				term_newln(p);
				break;
			}
			n = n->next;
		}
	} else {
		if (p->defindent == 0)
			p->defindent = 5;
		term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
		if (n != NULL) {
			if (n->tok != MDOC_Sh)
				term_vspace(p);
			print_mdoc_nodelist(p, NULL, meta, n);
		}
		term_end(p);
	}
}
예제 #9
0
파일: fbpad.c 프로젝트: pmamonov/fbpad
static int pollterms(void)
{
	struct pollfd ufds[NTERMS + 1];
	int term_idx[NTERMS + 1];
	int i;
	int n = 1;
	ufds[0].fd = 0;
	ufds[0].events = POLLIN;
	for (i = 0; i < NTERMS; i++) {
		if (TERMOPEN(i)) {
			ufds[n].fd = terms[i].fd;
			ufds[n].events = POLLIN;
			term_idx[n++] = i;
		}
	}
	if (poll(ufds, n, 1000) < 1)
		return 0;
	if (ufds[0].revents & (POLLFLAGS & ~POLLIN))
		return 1;
	if (ufds[0].revents & POLLIN)
		directkey();
	for (i = 1; i < n; i++) {
		if (!(ufds[i].revents & POLLFLAGS))
			continue;
		peepterm(term_idx[i]);
		if (ufds[i].revents & POLLIN) {
			term_read();
		} else {
			scr_free(term_idx[i]);
			term_end();
			if (cmdmode)
				exitit = 1;
		}
		peepback(term_idx[i]);
	}
	return 0;
}
예제 #10
0
void
terminal_man(void *arg, const struct man *man)
{
	struct termp		*p;
	const struct man_node	*n;
	const struct man_meta	*meta;
	struct mtermp		 mt;

	p = (struct termp *)arg;

	if (0 == p->defindent)
		p->defindent = 7;

	p->overstep = 0;
	p->maxrmargin = p->defrmargin;
	p->tabwidth = term_len(p, 5);

	if (NULL == p->symtab)
		p->symtab = mchars_alloc();

	n = man_node(man);
	meta = man_meta(man);

	term_begin(p, print_man_head, print_man_foot, meta);
	p->flags |= TERMP_NOSPACE;

	memset(&mt, 0, sizeof(struct mtermp));

	mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
	mt.offset = term_len(p, p->defindent);
	mt.pardist = 1;

	if (n->child)
		print_man_nodelist(p, &mt, n->child, meta);

	term_end(p);
}
예제 #11
0
파일: main.c 프로젝트: fujii/myd
void finish(int s){
  get_sel_end();
  term_end();
  myd_close(myd);
  exit(s);
}
예제 #12
0
파일: term_read.c 프로젝트: rsenn/shish
/* ----------------------------------------------------------------------- */
int term_read(int fd, char *buf, unsigned int len) {
  char c;
  int ret;
  static unsigned long remain;
          
  if(remain) {
  check_remain:
    if(len > remain)
      len = remain;
    byte_copy(buf, len, &term_cmdline.s[term_cmdline.len - remain]);
    remain -= len;
    if(!remain) {
      tcsetattr(fd, TCSANOW, &term_tcattr);
      stralloc_zero(&term_cmdline);
    }
    return len;
  }
    
/*  tcsetattr(fd, TCSANOW, &term_tcattr);*/
  term_attr(term_input.fd, 1);
  
  prompt_show();
    
  while((ret = buffer_getc(&term_input, &c)) > 0) {
    switch(c) {
      /* control-c discards the current line */
      case 3:
        stralloc_zero(&term_cmdline);
      /* newline */
      case '\n':
        term_newline();
        remain = term_cmdline.len;
        goto check_remain;
      /* control-a is HOME */
      case 1:
        term_home();
        break;
      /* control-e is END */
      case 5:
        term_end();
        break;
      /* control-d is EOF */
      case 4:
      if(!term_cmdline.len) {
          buffer_puts(term_output, "EOF");
          buffer_putnlflush(term_output);
          ret = 0;
          goto fail;
        }
        break;
      /* do the ANSI codes */
      case '\033':
        term_ansi();
        break;
      /* backspace */
      case 127:
      case '\b':
        term_backspace();
        break;
      /* printable chars */
      case '\t':
        c = ' ';
      default:
        if(term_insert)
          term_insertc(c);
        else
          term_overwritec(c);
        break;
    }
  }
fail:
  return ret;
}