Ejemplo n.º 1
0
int SLcurses_clearok (SLcurses_Window_Type *w, int bf)
{
   if (bf)
     {
	SLsmg_cls ();
	w->modified = 1;
     }
   return 0;
}
Ejemplo n.º 2
0
/*
 * Handle a "special request"
 */
static errr Term_xtra_sla(int n, int v)
{
	/* Analyze the request */
	switch (n)
	{
		/* Make a noise */
		case TERM_XTRA_NOISE:
		(void)SLsmg_write_char('\007');
		return (0);

		/* Flush the ncurses buffer */
		case TERM_XTRA_FRESH:
		(void)SLsmg_refresh();
		return (0);

		/* Make the cursor invisible or visible */
		case TERM_XTRA_SHAPE:
		/* curs_set(v); */
		return (0);

		/* Handle events */
		case TERM_XTRA_EVENT:
		return (Term_xtra_sla_event(v));

		/* Handle events */
		case TERM_XTRA_FLUSH:
		while (!Term_xtra_sla_event(FALSE));
		return (0);

		/* Suspend/Resume */
		case TERM_XTRA_ALIVE:
		return (Term_xtra_sla_alive(v));

		/* Clear the screen */
		case TERM_XTRA_CLEAR:
		(void)SLsmg_cls();
		SLsmg_gotorc(0, 0);
		return (0);

		/* Delay */
		case TERM_XTRA_DELAY:
		usleep(1000 * v);
		return (0);
	}

	/* Oops */
	return (1);
}
Ejemplo n.º 3
0
Archivo: screen.c Proyecto: hankem/jed
void jed_redraw_screen (int force)
{
   int row, center;
   Window_Type *w;
   Line *l;

   if (Batch) return;
   SLsmg_set_color (0);
   SLsmg_cls ();

   if (JScreen == NULL)
     return;

   for (row = 0; row < Jed_Num_Screen_Rows; row++)
     {
	/* JScreen[row].line = NULL; */
	JScreen[row].is_modified = 1;
     }

   if (NULL == (w = JWindow))
     return;

   center = JWindow->trashed;
   do
     {
	w->trashed = 1;
	w = w->next;
     }
   while(w != JWindow);

   if (center)
     {
	for (row = 0; row < JWindow->rows; row++)
	  {
	     JScreen[row + JWindow->sy].line = NULL;
	  }
	l = NULL;
     }
   else l = JWindow->beg.line;

   update(l, force, 0, 1);
}
Ejemplo n.º 4
0
/*
 * Nuke SLang
 */
static void Term_nuke_sla(term *t)
{
	if (!slang_on) return;

	/* Show the cursor */
	/* curs_set(1); */

	/* Clear the screen */
	(void)SLsmg_cls();

	/* Refresh */
	SLsmg_refresh();

	/* We are now off */
	slang_on = FALSE;

	/* Shut down */
	SLsmg_reset_smg();
	SLang_reset_tty();
}
Ejemplo n.º 5
0
int main(void) {
    SLtt_get_terminfo();

    SLtt_Use_Ansi_Colors = 1;

    SLsmg_init_smg();
    SLang_init_tty(4, 0, 0);

    SLsmg_cls();

    printall(0);
    SLsmg_set_char_set(1);
    printall(40);

    SLsmg_refresh();
    SLang_getkey();

    SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
    SLsmg_refresh();
    SLsmg_reset_smg();
    SLang_reset_tty();

    return 0;
}
Ejemplo n.º 6
0
static void most_do_help_text (void)
{
    char **p = help, *sect = NULL;
    int r;

    while (*p != NULL)
    {
        SLsmg_cls ();

        r = 0;
        SLsmg_gotorc (0, 0);

        if ((sect != NULL) && (**p == ' '))
        {
            most_tt_bold_video ();
            SLsmg_gotorc (r, 0);
            SLsmg_write_string (sect);
            most_tt_normal_video ();
            SLsmg_write_string (" (continued)");
            r += 2;
        }
        else sect = NULL;

        while (r < SLtt_Screen_Rows - 1)
        {
            if (*p == NULL) break;

            if (**p != ' ')
            {
                if (((r + 5) > SLtt_Screen_Rows)
                        && (**p != '*'))
                {
                    sect = NULL;
                    break;
                }

                if (sect != NULL)
                {
                    r++;
                }

                if (**p != '*')
                {
                    sect = *p;
                    most_tt_bold_video ();
                }
                else sect = NULL;
            }
            SLsmg_gotorc (r, 0);
            SLsmg_write_string (*p);

            if ((**p != ' ') && (**p != '*'))
            {
                most_tt_normal_video ();
                r++;
            }
            p++;
            r++;
        }

        SLsmg_gotorc (r, 0);

        most_tt_reverse_video();
        SLsmg_write_string("Press any key to continue.");
        most_tt_normal_video();

        SLsmg_refresh ();

        most_getkey ();
    }

    most_redraw_display();
}
Ejemplo n.º 7
0
/*ARGSUSED*/
static int ctl_open(int using_stdin, int using_stdout)
{
#ifdef TIOCGWINSZ
  struct winsize size;
#endif
  int i;
  int save_lines, save_cols;

  SLtt_get_terminfo();
/*
 * Save the terminfo values for lines and cols
 * then detect the real values.
 */
  save_lines = SLtt_Screen_Rows;
  save_cols = SLtt_Screen_Cols;
#ifdef TIOCGWINSZ
  if (!ioctl(0, TIOCGWINSZ, &size)) {
    SLtt_Screen_Cols=size.ws_col;
    SLtt_Screen_Rows=size.ws_row;
  } else
#endif
  {
    SLtt_Screen_Cols=atoi(getenv("COLUMNS"));
    SLtt_Screen_Rows=atoi(getenv("LINES"));
  }
  if (!SLtt_Screen_Cols || !SLtt_Screen_Rows) {
    SLtt_Screen_Rows = save_lines;
      SLtt_Screen_Cols = save_cols;
  }
  SLang_init_tty(7, 0, 0);
  SLsmg_init_smg();
  SLtt_set_color (20, "Normal", "lightgray", "black");
  SLtt_set_color (21, "HighLight", "white", "black");
  SLtt_set_color (22, "Reverse", "black", "white");
  SLtt_Use_Ansi_Colors = 1;
  SLtt_Term_Cannot_Scroll = 1;

  ctl.opened=1;

  SLsmg_cls();

  ctl_head();

  SLsmg_printfrc(3,0, "File:");
  if (ctl.trace_playing)
    {
      SLsmg_printfrc(4,0, "Time:");
      SLsmg_gotorc(4,6+6+1);
      SLsmg_write_char('/');
      SLsmg_gotorc(4,40);
      SLsmg_printf("Voices:    / %d", voices);
    }
  else
    {
      SLsmg_printfrc(4,0, "Time:");
      SLsmg_printfrc(4,13, "/");
    }
  SLsmg_printfrc(4,SLtt_Screen_Cols-20, "Master volume:");
  SLsmg_gotorc(5,0);
  for (i=0; i<SLtt_Screen_Cols; i++)
    SLsmg_write_char('_');
  if (ctl.trace_playing)
    {
      SLsmg_printfrc(6,0, "Ch");
      SLsmg_printfrc(6,SLtt_Screen_Cols-20, "Prg Vol Exp Pan S B");
      SLsmg_gotorc(7,0);
      for (i=0; i<SLtt_Screen_Cols; i++)
      SLsmg_write_char('-');
      for (i=0; i<16; i++)
      {
        SLsmg_printfrc(8+i, 0, "%02d", i+1);
      }
      set_trace_loop_hook(update_indicator);
      indicator_width=SLtt_Screen_Cols-2;
      if(indicator_width<40)
	indicator_width=40;
      lyric_row=2;
    }
  else
    msg_row = 6;
  memset(comment_indicator_buffer =
    (char *)safe_malloc(indicator_width), 0, indicator_width);
  memset(current_indicator_message =
    (char *)safe_malloc(indicator_width), 0, indicator_width);
  _ctl_refresh();

  return 0;
}
Ejemplo n.º 8
0
/* displays a selection of limited (visible) emails */
void redraw_current_state() {
  int r = 0;
  mbox_item *e;

  SLsig_block_signals();

  disp.num_rows = SLtt_Screen_Rows;
  disp.num_cols = SLtt_Screen_Cols;

  SLsmg_normal_video();

  if( emails.num_limited > 0 ) {
    for(r = 0; r < (disp.num_rows - 2); r++) {
      if( r + disp.first_visible < emails.num_limited ) {
	
	e = emails.llist[r + disp.first_visible];
	
	SLsmg_gotorc(r + 1, 0);
	SLsmg_printf("%c %8.1f %s", 
		     (e->state & (1<<STATE_TAGGED)) ? 'T' : ' ',
		     e->score[emails.score_type],
		     e->description[emails.index_format]);
	SLsmg_erase_eol();
      } else {
	SLsmg_gotorc(r + 1, 0);
	SLsmg_erase_eol();
      }
    }
  } else {
    SLsmg_cls();
    r = disp.num_rows - 2;
  }

  SLsmg_reverse_video();


  e = emails.llist[disp.first_visible + disp.highlighted];

  SLsmg_gotorc(disp.highlighted + 1, 0);
  
  if( emails.num_limited > 0 ) {
    SLsmg_printf("%c %8.1f %s", 
		 (e->state & (1<<STATE_TAGGED)) ? 'T' : ' ',
		 e->score[emails.score_type],
		 e->description[emails.index_format]);
  }
  SLsmg_erase_eol();

  SLsmg_set_color(2);

  SLsmg_gotorc(0,0);
  SLsmg_printf("mailinspect %s %ld msgs sorted(%d) by category %s", 
	       emails.filename, (long)emails.num_limited, emails.score_type, cat[0].filename);
  SLsmg_erase_eol();

  SLsmg_gotorc(r + 1, 0);
  SLsmg_printf("q: quit o: scoring z: rev. sort /: search tT: tag uU: untag sS: send to shell p: summary c: category");
  SLsmg_erase_eol();
  SLsmg_refresh();

  SLsig_unblock_signals();

}
Ejemplo n.º 9
0
static int slang_init_graphics(caca_display_t *dp)
{
    dp->drv.p = malloc(sizeof(struct driver_private));
    dp->drv.p->sigint_event = 0;

#if defined(HAVE_GETENV) && defined(HAVE_PUTENV)
    slang_install_terminal(dp);
#endif

#if defined(HAVE_SIGNAL)
    sigwinch_d = dp;
    signal(SIGWINCH, sigwinch_handler);
#endif

    _caca_set_term_title("caca for S-Lang");

    /* Initialise slang library */
    SLsig_block_signals();
    /* Disable SLang's own SIGINT on ctrl-c */
    SLang_set_abort_signal(default_sigint);

    SLtt_get_terminfo();

    if(SLkp_init() == -1)
    {
        SLsig_unblock_signals();
        return -1;
    }

    SLang_init_tty(-1, 0, 1);

    if(SLsmg_init_smg() == -1)
    {
        SLsig_unblock_signals();
        return -1;
    }

    SLsmg_cls();
    SLtt_set_cursor_visibility(0);
    SLkp_define_keysym("\e[M", 1001);
    SLtt_set_mouse_mode(1, 0);
    SLsmg_refresh();

    /* Disable scrolling so that hashmap scrolling optimization code
     * does not cause ugly refreshes due to slow terminals */
    SLtt_Term_Cannot_Scroll = 1;

    slang_init_palette();

#if defined(VMS) || defined(REAL_UNIX_SYSTEM)
    /* Disable alt charset support so that we get a chance to have all
     * 256 colour pairs */
    SLtt_Has_Alt_Charset = 0;
#endif

#ifdef HAVE_SLSMG_UTF8_ENABLE
    SLsmg_utf8_enable(1); /* 1 == force, 0 == disable, -1 == autodetect */
    SLtt_utf8_enable(1);
#endif

    caca_add_dirty_rect(dp->cv, 0, 0, dp->cv->width, dp->cv->height);
    dp->resize.allow = 1;
    caca_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);
    dp->resize.allow = 0;

    SLsig_unblock_signals();

    return 0;
}
Ejemplo n.º 10
0
static void smg_cls (void)
{
   if (Smg_Initialized <= 0)
     return;
   SLsmg_cls ();
}
Ejemplo n.º 11
0
static int sl_output(int port, char *buf, int len)
{
    int x,y,z,v,w;
    char *str, *t1, *t2, *t3;
    int ret;
    char ch;


    /* check for signals */

    if (signal_cought != 0) {  /* async out signal */
	char xxx[5];

	xxx[0] = 0;
	put_int32(signal_cought, xxx+1);
	driver_output(port, xxx, 5);
	signal_cought = 0;
    }

    switch (*buf++) {
    case INIT_TTY: {
	int abort_char, flow_ctl, opost;
	abort_char = get_int32(buf); buf+=4;
	flow_ctl = get_int32(buf); buf+= 4;
	opost = get_int32(buf); buf+= 4;
	ret = SLang_init_tty (abort_char,flow_ctl, opost);
	return ret_int(port, ret);
    }
    
    case SET_ABORT_FUNCTION: {
	SLang_set_abort_signal (NULL);
	return ret_int(port, 0);
    }
    case GETKEY: {
	unsigned int key;
	if (SLang_input_pending (0) == 0) {
	    wait_for = GETKEY;
	    driver_select(port, 0, DO_READ, 1);
	    return 0;
	}
	x = SLang_getkey ();
	return ret_int(port, x);
    }
    /* read a symbol */
    case KP_GETKEY: {
	if (SLang_input_pending (0) == 0) {
	    wait_for = KP_GETKEY;
	    driver_select(port, 0, DO_READ, 1);
	    return 0;
	}
	x = SLkp_getkey ();
	return ret_int(port, x);
    }
    case UNGETKEY: {
	unsigned char  key =  (unsigned char) *buf;
	SLang_ungetkey (key); 
	return 0;
    }
    case RESET_TTY: {
	SLang_reset_tty();
	return 0;
    }
    case KP_INIT: {
	return ret_int(port, SLkp_init ());
    }
    case SETVAR: {
	x = get_int32(buf);buf+= 4;
	y = get_int32(buf);
	switch (x) {
	case  esl_baud_rate:
	    SLang_TT_Baud_Rate = y; return 0;
	case esl_read_fd:
	    return 0;
	case esl_abort_char:
	    SLang_Abort_Char = y; return 0;
	case esl_ignore_user_abort:
	    SLang_Ignore_User_Abort=y; return 0;
	case esl_input_buffer_len :
	    SLang_Input_Buffer_Len=y; return 0;
	case  esl_keyboard_quit:
	    SLKeyBoard_Quit=y; return 0;
	case esl_last_key_char:
	    SLang_Last_Key_Char=y; return 0;
	case esl_rl_eof_char:
	    SLang_RL_EOF_Char=y; return 0;
	case esl_rline_quit:
	    SLang_Rline_Quit=y; return 0;
	case esl_screen_rows:
	case  esl_screen_cols :
	    return 0;
	case esl_tab_width:
	    SLsmg_Tab_Width=y; return 0;
	case  esl_newline_behaviour:
	    SLsmg_Newline_Behavior=y; return 0;
	case esl_error:
	    SLang_Error=y; return 0;
	case esl_version:
	    return 0;
	case  esl_backspace_moves :
	    SLsmg_Backspace_Moves=y; return 0;
	case esl_display_eight_bit:
	    SLsmg_Display_Eight_Bit=y; return 0;
	default:
	    return 0;
	}
    }

    case GETVAR: {
	x = get_int32(buf);
	switch (x) {
	case  esl_baud_rate:
	    return ret_int(port, SLang_TT_Baud_Rate);
	case esl_read_fd:
	    return ret_int(port,  SLang_TT_Read_FD);
	case esl_abort_char:
	    return (ret_int(port, SLang_Abort_Char));
	case esl_ignore_user_abort:
	    return ret_int(port, SLang_Ignore_User_Abort);
	case esl_input_buffer_len :
	    return ret_int(port, SLang_Input_Buffer_Len);
	case  esl_keyboard_quit:
	    return ret_int(port, SLKeyBoard_Quit);
	case esl_last_key_char:
	    return ret_int(port, SLang_Last_Key_Char);
	case esl_rl_eof_char:
	    return ret_int(port, SLang_RL_EOF_Char);
	case esl_rline_quit:
	    return ret_int(port, SLang_Rline_Quit);
	case esl_screen_rows:
	    return ret_int(port, SLtt_Screen_Rows);
	case  esl_screen_cols :
	    return ret_int(port, SLtt_Screen_Cols);
	case esl_tab_width:
	    return ret_int(port, SLsmg_Tab_Width);
	case  esl_newline_behaviour:
	    return ret_int(port, SLsmg_Newline_Behavior);
	case esl_error:
	    return ret_int(port, SLang_Error);
	case esl_version:
	    return ret_int(port, SLang_Version); 
	case  esl_backspace_moves :
	    return ret_int(port, SLsmg_Backspace_Moves);
	case esl_display_eight_bit:
	    return  ret_int(port, SLsmg_Display_Eight_Bit);
	default:
	    return ret_int(port, -1);
	}
    }
	    


    /*{{{ SLsmg Screen Management Functions */


    
    case SMG_FILL_REGION: {
	x = get_int32(buf); buf+= 4;
	y =  get_int32(buf); buf+= 4;
	z = get_int32(buf); buf+= 4;
	v = get_int32(buf); buf+= 4;
	ch = *buf;
	SLsmg_fill_region(x, y,z,v,ch);
	return 0;
    }			  
    case SMG_SET_CHAR_SET: {
	x = get_int32(buf); buf+= 4;
	SLsmg_set_char_set(x);
	return 0;
    }			
    case SMG_SUSPEND_SMG: {
	return ret_int(port, SLsmg_suspend_smg());
    }				  
    case SMG_RESUME_SMG: {
	ret_int(port, SLsmg_resume_smg());
    }				     
    case SMG_ERASE_EOL: {
	SLsmg_erase_eol();
	return 0;
    }					
    case SMG_GOTORC: {
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	SLsmg_gotorc(x,  y);
	return 0;
    }					 
    case SMG_ERASE_EOS: {
	SLsmg_erase_eos();
	return 0;
    }						
    case SMG_REVERSE_VIDEO: {
	SLsmg_reverse_video();
	return 0;
    }							
    case SMG_SET_COLOR: {
	x = get_int32(buf); buf+= 4;
	SLsmg_set_color(x);
	return 0;
    }							
    case SMG_NORMAL_VIDEO: {
	SLsmg_normal_video();
	return 0;
    }							
    case SMG_WRITE_STRING: {
	SLsmg_write_string(buf);
	return 0;
    }									   
    case SMG_WRITE_CHAR: {
	ch = *buf;
	SLsmg_write_char(ch);
	return 0;
    }
    case SMG_WRITE_WRAPPED_STRING: {
	t1 = buf;
	buf += strlen(t1) + 1;
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	z = get_int32(buf); buf+= 4;
	v = get_int32(buf); buf+= 4;
	w = get_int32(buf); buf+= 4;
	SLsmg_write_wrapped_string(t1, x,y,z,v,w);
	return 0;
    }												   
    case SMG_CLS: {
	SLsmg_cls();
	return 0;
    }									
    case SMG_REFRESH: {
	SLsmg_refresh();
	return 0;
    }										
    case SMG_TOUCH_LINES: {
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	SLsmg_touch_lines(x, y);
	return 0;
    }											
    case SMG_TOUCH_SCREEN: {
#if (SLANG_VERSION < 10400 )
	return ret_int(port, -1);
#else
	SLsmg_touch_screen();
#endif
	return 0;
    }													   
    case SMG_INIT_SMG: {
	return ret_int(port,  SLsmg_init_smg());
    }													   
    case SMG_REINIT_SMG: {
#if (SLANG_VERSION < 10400 )
	return ret_int(port, -1);
#else
	return ret_int(port, SLsmg_reinit_smg());
#endif
    }														 
    case SMG_RESET_SMG: {
	SLsmg_reset_smg();
	return 0;
    }														    
    case SMG_CHAR_AT: {
	return ret_int(port, SLsmg_char_at());
    }														     
    case SMG_SET_SCREEN_START: {
	int *ip1, *ip2;
	*ip1 = get_int32(buf); buf+= 4;
	*ip2 = get_int32(buf); buf+= 4;

	SLsmg_set_screen_start(ip1, ip2);
	return ret_int_int(port, *ip1, *ip2);
    }
    case SMG_DRAW_HLINE: {
	x = get_int32(buf); buf+= 4;
	SLsmg_draw_hline(x);
	return 0;
    }																 
    case SMG_DRAW_VLINE: {
	x = get_int32(buf); buf+= 4;
	SLsmg_draw_vline(x);
	return 0;
    }																     
    case SMG_DRAW_OBJECT: {
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	x = get_int32(buf); buf+= 4;
	SLsmg_draw_object(x, y,z);
	return 0;
    }																	  
    case SMG_DRAW_BOX: {
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	z = get_int32(buf); buf+= 4;
	v = get_int32(buf); buf+= 4;
	SLsmg_draw_box(x, y,z,v);
	return 0;
    }																	   
    case SMG_GET_COLUMN: {
	return ret_int(port, SLsmg_get_column());
    }																		
    case SMG_GET_ROW: {
	return ret_int(port, SLsmg_get_row());
    }		

    case SMG_FORWARD: {
	x = get_int32(buf); buf+= 4;
	SLsmg_forward(x);
	return 0;
    }							
    case SMG_WRITE_COLOR_CHARS: {
	SLsmg_Char_Type * sl;
	sl = decode_smg_char_type(&buf);
	x = get_int32(buf); buf+= 4;
	SLsmg_write_color_chars(sl, x);
	return 0;
    }		
    case SMG_READ_RAW: {
	x = get_int32(buf); buf+= 4;
	t1 = malloc((2*x) + 2 + 1);
	y = SLsmg_read_raw((unsigned short*)t1 +1, x);
	t1[1] = 1;
	driver_output(port, t1, y+1);
	free(t1);
	return 0;
    }
    case SMG_WRITE_RAW: {
	SLsmg_Char_Type * sl;
	sl = decode_smg_char_type(&buf);
	x = get_int32(buf); 
	y = SLsmg_write_raw(sl, x);
	return ret_int(port, y);
    }																				
    case SMG_SET_COLOR_IN_REGION: {
	x = get_int32(buf); buf+= 4;
	y = get_int32(buf); buf+= 4;
	z = get_int32(buf); buf+= 4;
	v = get_int32(buf); buf+= 4;
	w = get_int32(buf); buf+= 4;
	SLsmg_set_color_in_region(x, y,z,v,w);
	return 0;
    }																				
    
    




    /* all the tt_functions  */

    case TT_FLUSH_OUTPUT: {
	ret = SLtt_flush_output();
	return ret_int(port, ret);
    }
    case TT_SET_SCROLL_REGION: {

	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	SLtt_set_scroll_region(x, y);
	return 0;
    }
    case TT_RESET_SCROLL_REGION: {
	SLtt_reset_scroll_region();
	return 0;
    }
    case TT_REVERSE_VIDEO: {
	SLtt_reverse_video (get_int32(buf));
	return 0;
    }
    case TT_BOLD_VIDEO: {
	SLtt_begin_insert();
	return 0;
    }
    case TT_BEGIN_INSERT: {
	SLtt_begin_insert();
	return 0;
    }
    case TT_END_INSERT: {
	SLtt_end_insert();
	return 0;
    }
    case TT_DEL_EOL: {
	SLtt_del_eol();
	return 0;
    }
    case TT_GOTO_RC: {
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	SLtt_goto_rc (x, y);
	return 0;
    }
    case TT_DELETE_NLINES: {
	SLtt_delete_nlines(get_int32(buf));
	return 0;
    }
    case TT_DELETE_CHAR: {
	SLtt_delete_char();
	return 0;
    }
    case TT_ERASE_LINE: {
	SLtt_erase_line();
	return 0;
    }
    case TT_NORMAL_VIDEO: {
	SLtt_normal_video();
	return 0;
    }
    case TT_CLS: {
	SLtt_cls();
	return 0;
    }
    case TT_BEEP: {
	SLtt_beep();
	return 0;
    }
    case TT_REVERSE_INDEX: {
	SLtt_reverse_index(get_int32(buf));
	return 0;
    }
    case TT_SMART_PUTS: {
	SLsmg_Char_Type *t1 ;
	SLsmg_Char_Type *t2;

	t1 = decode_smg_char_type(&buf);
	t2 = decode_smg_char_type(&buf);
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	SLtt_smart_puts(t1, t2,x,y);
	return 0;
    }
    case TT_WRITE_STRING: {
	SLtt_write_string (buf);
	return 0;
    }
    case TT_PUTCHAR: {
	SLtt_putchar((char) get_int32(buf));
	return 0;
    }
    case TT_INIT_VIDEO: {
	ret = SLtt_init_video ();
	return ret_int(port, ret);	
    }
    case TT_RESET_VIDEO: {
	SLtt_reset_video ();
	return 0;
    }
    case TT_GET_TERMINFO: {
	SLtt_get_terminfo();
	return 0;
    }
    case TT_GET_SCREEN_SIZE: {
	SLtt_get_screen_size ();
	return 0;
    }
    case TT_SET_CURSOR_VISIBILITY: {
	ret = SLtt_set_cursor_visibility (get_int32(buf));
	return ret_int(port, ret);	
    }
    case TT_SET_MOUSE_MODE: {
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	ret = SLtt_set_mouse_mode (x,y);
	return ret_int(port, ret);	
    }

    case TT_INITIALIZE: {
	ret =SLtt_initialize (buf);
	return ret_int(port, ret);	
    }
    case TT_ENABLE_CURSOR_KEYS: {
	SLtt_enable_cursor_keys();
	return 0;
    }
    case TT_SET_TERM_VTXXX: {
	
	return 0;
    }
    case TT_SET_COLOR_ESC: {
	x = get_int32(buf); buf+=4;
	SLtt_set_color_esc (x, buf);
	return 0;
    }
    case TT_WIDE_WIDTH: {
	SLtt_narrow_width();
	return 0;
    }
    case TT_NARROW_WIDTH: {
	SLtt_narrow_width();
	return 0;
    }
    case TT_SET_ALT_CHAR_SET: {
	SLtt_set_alt_char_set (get_int32(buf));
	return 0;
    }
    case TT_WRITE_TO_STATUS_LINE: {
	x = get_int32(buf); buf+=4;
	SLtt_write_to_status_line (buf, x);
	return 0;
    }
    case TT_DISABLE_STATUS_LINE: {
	SLtt_disable_status_line ();
	return 0;
    }


    case TT_TGETSTR: {
	str = SLtt_tgetstr (buf);
	return ret_string(port, str);
    }
    case TT_TGETNUM: {
	x = SLtt_tgetnum (buf);
	return ret_int(port, x);
    }
    case TT_TGETFLAG: {
	x = SLtt_tgetflag (buf);
	return  ret_int(port, x);
    }
    case TT_TIGETENT: {
	str = SLtt_tigetent (buf);
	return ret_string(port, str);
    }
    case TT_TIGETSTR: {
	
	return 0;
    }
    case TT_TIGETNUM: {

	return 0;
    }

    case SLTT_GET_COLOR_OBJECT: {
	x = get_int32(buf); buf+=4;
	y = SLtt_get_color_object (x);
	return  ret_int(port, y);
	return 0;
    }
    case TT_SET_COLOR_OBJECT: {
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	SLtt_set_color_object (x, y);
	return 0;
    }
    case TT_SET_COLOR: {
	x = get_int32(buf); buf+=4;
	t1 = buf;
	t2 = buf + (strlen(t1) + 1);
	t3 = buf + (strlen(t1) + strlen(t2) + 2);
	SLtt_set_color (x, t1, t2, t3);
	return 0;
    }
    case TT_SET_MONO: {
	x = get_int32(buf); buf+=4;
	t1 = buf;
	buf += strlen(t1) + 1;
	y = get_int32(buf);
	SLtt_set_mono (x, t1, y);
	return 0;
    }
    case TT_ADD_COLOR_ATTRIBUTE: {
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	SLtt_add_color_attribute (x, y);
	return 0;
    }
    case TT_SET_COLOR_FGBG: {
	x = get_int32(buf); buf+=4;
	y = get_int32(buf); buf+=4;
	z = get_int32(buf); buf+=4;
	SLtt_set_color_fgbg (x, y, z);
	return 0;
    }
    case ISATTY: {
	x = get_int32(buf); buf+=4;
	return ret_int(port, isatty(x));
    }
    case EFORMAT: {
	fprintf(stderr, "%s", buf);
	fflush(stderr);
	return 0;
    }
    case SIGNAL: {
	x = get_int32(buf); buf+=4;
	SLsignal(x_to_sig(x), sig_handler);
	return 0;
    }
    case SIGNAL_CHECK: {
	/* polled */
	if (signal_cought != 0)
	    signal_cought = 0;
	return ret_int(port, signal_cought);
    }

    default:
	return 0;
    }
}
Ejemplo n.º 12
0
/* 
 * Run a command from the menus.
 */
void RunCommand (Menu_Item_Type *i) {
  char *command;
  int must_redraw=0;
  Conditional_String *cs=NULL;
  Window_List_Type *this_window=CurrentWindow;

  if (i->command[0] != '\0') { /* don't try to run a null command */

    if (i->edit_flag) { /* edit command on fly */
      cs=EditTags(i->command);
      if (cs->ignore) { /* user hit escape */
	free(cs->value);
	free(cs);
	return;
      }
      else { /* user hit enter */
	command=malloc(strlen(cs->value)+1);
	strcpy(command,cs->value);
	free(cs->value);
	free(cs);
      }
    }
    else { /* don't edit command on fly */
      command=malloc(strlen(i->command)+1);
      strcpy(command,i->command);
    }

#ifdef SETENV_FLAG_OK
    if (i->setenv_flag) { /* a setenv command */
      RunSetenv(command);
    }
    else
#endif
      if (i->makemenu_flag) { /* process command output as rc file */
	ReadRc(command,RC_PREPROC);
	SanityCheckMenus();
	/*
	 * make sure that all modified menus currently on screen
	 * get recalced.
	 */
	while (this_window) {
	  if (this_window->menu->recalc) {
	    CalcMenu(this_window->menu);
	    must_redraw=1;
	  }
	  this_window=this_window->last;
	}
	if (must_redraw)
	  DrawAll();
      }
      else if (i->truncate_flag) { /* display in a window and truncate */
	RunShow(i->text,command,1);
      }
      else if (i->display_flag) {	/* display in a window and wrap. */
	RunShow(i->text,command,0);
      }
      else { /* normal display */
	if (! i->noclear_flag) {
				/* clear screen */
	  SLsmg_cls();
	  SLsmg_normal_video();
	  Screen_Reset();
#ifdef GPM_SUPPORT
	  EndMouse(); /* return to normal GPM/selection mode */
#endif
	}

	/* 
	 * This is what the whole pdmenu program comes down to.
	 * The rest is fluff. ;-) 
	 */

	/*
	 * start: Steve Blott ([email protected])
	 *
	 * add capability to exec() (rather than system()) a command, thereby
	 * replacing the current process;  if the first word of command is
	 * "exec", then exec() it, otherwise system() it
	 */

	char *cp = command;

        while (isspace(cp[0]))
	   cp++;

	if ( strncmp(cp, "exec", 4) == 0 && isspace(cp[4]) )
	{
	   char *cv[4]; /* command vector */
	   cv[0] = "sh";
	   cv[1] = "-c";
	   cv[2] = cp;
	   cv[3] = 0;
	   execvp(cv[0],cv);
	   /* should not reach here; if the execvp fails, then pdmenu will
	    * continue to run, silently ignoring the failure; if the execvp
	    * succeeds but the subsequent exec fails, then pdmenu will silently
	    * disappear (its process no longer exists), and no feedback will be
	    * received */
	}
	else
	   system(command);

	if (! i->noclear_flag) { /* redraw screen */
	  Screen_Init();
			
	  if (i->pause_flag) { /* pause 1st */
	    printf("\n%s",_("Press Enter to return to Pdmenu."));
	    fflush(stdout); /* make sure above is displayed. */
	    /* Now wait for the keypress. */
	    while (1) {
		    int k;
		    k = SLang_getkey();
		    if (k == '\n' || k == '\r') {
			    break;
		    }
	    }
	    SLang_flush_input(); /* kill any buffered input */
	    printf("\n");
	  }

#ifdef GPM_SUPPORT
	  gpm_ok=InitMouse(); /* grab mouse pointer again. */
#endif

	  /* 
	   * we need to account for the screen size changing behind our backs
	   * while the program was running.
	   */
	  SetScreensize();
	  Resize_Screen();
	  DrawAll();
	}
      }
    free(command);
  }
}