예제 #1
0
파일: window.c 프로젝트: HariniParth/tos
void output_char(WINDOW* wnd, unsigned char c)
{
	remove_cursor(wnd);
	switch(c){
		case '\n':
		case 13:
					wnd->cursor_x = 0;
					wnd->cursor_y++;
					break;
		case '\b':
					if(wnd->cursor_x!=0){
						wnd->cursor_x--;
					} else { 
						if(wnd->cursor_y!=0){
							wnd->cursor_x = wnd->width - 1;
							wnd->cursor_y--;
					  }
					}
					break;
		default:
					poke_screen(wnd->x + wnd->cursor_x,wnd->y + wnd->cursor_y,(short unsigned int) c | (default_color << 8));
					wnd->cursor_x++;
					if(wnd->cursor_x == wnd->width){
						wnd->cursor_x = 0;
						wnd->cursor_y++;
					}
					break;
		}
	if(wnd->cursor_y == wnd->height)
		scroll_window(wnd);
	show_cursor(wnd);
}
예제 #2
0
파일: cfgkeys.c 프로젝트: eposts/Rich
void position_cursor( HELP_WINDOW *hw, int len, int *un, int *cc, int *ch )
{
int col, row, y, yy;

   col = hw->ulft_col + hw->dply_col;
   row = hw->ulft_row + hw->dply_row + hw->v_row;
   y  = hw->ulft_row + hw->dply_row;
   yy = hw->ulft_row + hw->dply_row + hw->avail_lines - 1;
   *un = FALSE;
   switch (*ch) {
      case UP    :
         if (hw->v_row > 0 && hw->select > 0) {
            hlight_line( col, row, len, NORMAL );
            --hw->v_row;
            --hw->select;
            *cc = TRUE;
         } else if (hw->v_row == 0 && hw->select > 0) {
            hlight_line( col, row, len, NORMAL );
            --hw->select;
            scroll_window( -1, y, col, yy+1, col+hw->line_length, NORMAL );
            *un = TRUE;
            *cc = TRUE;
         }
         break;
      case DOWN :
         if (hw->v_row < hw->avail_lines-1 &&
                                      hw->select < hw->num_entries-1) {
            hlight_line( col, row, len, NORMAL );
            ++hw->v_row;
            ++hw->select;
            *cc = TRUE;
         } else if (hw->v_row == hw->avail_lines-1 &&
                                      hw->select < hw->num_entries-1) {
            hlight_line( col, row, len, NORMAL );
            ++hw->select;
            scroll_window( 1, y, col, yy, col+hw->line_length, NORMAL );
            *un = TRUE;
            *cc = TRUE;
         } else if (hw->select == hw->num_entries - 1 && hw->v_row > 0) {
            --hw->v_row;
            scroll_window(1, y, col, yy, col+hw->line_length, NORMAL );
         }
         break;
   }
}
예제 #3
0
int amx_putstr(const TCHAR *format)
{
  if (createconsole(0, NULL)) {
    int pos, i;

    pos=csry * NUM_COLUMNS + csrx;
    assert(lines!=NULL);
    for (i=0; string[i]!=__T('\0'); i++) {
      if (csry<NUM_LINES && csrx<NUM_COLUMNS) {
        if (string[i]==__T('\r')) {
          csrx=0;
          pos=csry * NUM_COLUMNS + csrx;
        } else if (string[i]==__T('\n')) {
          csrx=0;
          csry++;
          if (csry>=NUM_LINES)
            scroll_window(0, -1);
          pos=csry * NUM_COLUMNS + csrx;
        } else if (string[i]==__T('\b')) {
          if (csrx>0) {
            csrx--;
            pos--;
            lines[pos]=__T(' ');
            //??? lines[pos+1]=attrib;
          } /* if */
        } else {
          lines[pos]=string[i];
          //??? lines[pos+1]=attrib;
          pos++;
          csrx++;
          if (csrx>=NUM_COLUMNS && autowrap) {
            csrx=0;
            csry++;
            if (csry>=NUM_LINES)
              scroll_window(0, -1);
            pos=csry * NUM_COLUMNS + csrx;
          } /* if */
        } /* if */
      } /* if */
    } /* for */
    refresh_screen(csry,csry+1);
  } /* if */
  return 0;
}
예제 #4
0
bool process_output( link_data* link )
{
  text_data*      output;
  text_data*        next;
  char_data*          ch  = link->character;
  bool        status_bar;

  if( link->connected == CON_PLAYING && ch == NULL ) {
    bug( "Process_Output: Link playing with null character." );
    bug( "--     Host = '%s'", link->host );
    bug( "-- Rec_Prev = '%s'", link->rec_prev );
    return FALSE;
    }

  status_bar = ( link->connected == CON_PLAYING
    && is_set( ch->pcdata->pfile->flags, PLR_STATUS_BAR )
    && ch->pcdata->terminal != TERM_DUMB );

  if( link->send == NULL && !link->command )
    return TRUE;

  /* SAVE CURSOR */

  if( status_bar ) {
    next       = link->send;
    link->send = NULL;
    scroll_window( ch );
    if( next != NULL )
      send( ch, "\n\r" );
    cat( link->send, next );
    prompt_ansi( link );
    command_line( ch );
    }
  else {
    if( !link->command ) {
      next       = link->send;
      link->send = NULL;
      send( ch, "\n\r" );
      cat( link->send, next );
      }  
    if( link->connected == CON_PLAYING && link->receive == NULL ) 
      prompt_nml( link );
    }

  /* SEND OUTPUT */

  for( ; ( output = link->send ) != NULL; ) {
    if( int( write( link->channel, output->message.text,
      output->message.length ) ) == -1 )
      return FALSE; 
    link->send = output->next;
    delete output;
    }

  return TRUE;
}
예제 #5
0
/** Run a selected suite within the curses interface.
 * Displays actions and responds based on user imput.
 * @param pSuite The suite to use for testing (non-NULL).
 */
static STATUS curses_suite_level_run(CU_pSuite pSuite)
{
  char szTestName[STRING_LENGTH];
  CU_pTest pTest = NULL;

  f_szOptions = SUITE_OPTIONS;
  refresh_options_window();

  while (true) {
    int option = toupper(getch());

    switch (option) {
      case 'R':
        curses_run_suite_tests(pSuite);
        break;

      case 'S':
        read_input_string("Enter Test Name : ", szTestName, STRING_LENGTH);
        if (NULL != (pTest = CU_get_test_by_name(szTestName, pSuite))) {
          curses_run_single_test(pSuite, pTest);
        }
        refresh_details_window();
        break;

      case 'L':
        list_tests(pSuite);
        break;

      case 'F':
        show_failures();
        break;

      case 'U':
        return CONTINUE;

      case 'Q':
        return STOP;

      case KEY_UP:
      case KEY_DOWN:
      case KEY_RIGHT:
      case KEY_LEFT:
        scroll_window(option, &details_pad, refresh_details_window);
        break;

      default:
        break;
    }
  }

  return CONTINUE;
}
예제 #6
0
파일: cfgkeys.c 프로젝트: eposts/Rich
void show_func_list( HELP_WINDOW *hw, char *func[] )
{
int row, col, i, j;

   col = hw->ulft_col + hw->dply_col;
   row = hw->ulft_row + hw->dply_row;
   scroll_window( 0, row, col, row+hw->avail_lines-1, col+hw->line_length,
                  NORMAL );
   i = 0;
   j = hw->select - hw->v_row;
   for (; i < hw->avail_lines && j<hw->num_entries; ++i, j++, row++)
      s_output( func[j], row, col, NORMAL );
}
예제 #7
0
/** Main loop for curses interface.
 * Displays actions and responds based on user imput.
 * @param pRegistry The CU_pTestRegistry to use for testing (non-NULL).
 */
static STATUS curses_registry_level_run(CU_pTestRegistry pRegistry)
{
  char szSuiteName[STRING_LENGTH];
  CU_pSuite pSuite = NULL;
  bool bContinue = true;

  while (bContinue) {
    int option = toupper(getch());

    switch (option) {
      case 'R':
        curses_run_all_tests(pRegistry);
        break;

      case 'S':
        read_input_string("Enter Suite Name : ", szSuiteName, STRING_LENGTH);
        refresh_details_window();
        if (NULL != (pSuite = CU_get_suite_by_name(szSuiteName, (NULL == pRegistry) ? pRegistry : CU_get_registry()))) {
          if (STOP == curses_suite_level_run(pSuite)) {
            bContinue = false;
          }
          f_szOptions = MAIN_OPTIONS;
          refresh_options_window();
        }
        break;

      case 'L':
        list_suites(pRegistry);
        break;

      case 'F':
        show_failures();
        break;

      case 'Q':
        return bContinue = false;

      case KEY_UP:
      case KEY_DOWN:
      case KEY_RIGHT:
      case KEY_LEFT:
        scroll_window(option, &details_pad, refresh_details_window);
        break;

      default:
        break;
    }
  }

  return STOP;
}
예제 #8
0
파일: cfgkeys.c 프로젝트: eposts/Rich
void show_key_def_list( HELP_WINDOW *hw, KEY_DEFS *keys )
{
int row, col, i, j;

   col = hw->ulft_col + hw->dply_col;
   row = hw->ulft_row + hw->dply_row;
   scroll_window( 0, row, col, row+hw->avail_lines-1, col+hw->line_length,
                  NORMAL );
   i = 0;
   j = hw->select - hw->v_row;
   for (; i < hw->avail_lines && j<hw->num_entries; ++i, j++, row++) {
      s_output( keys[j].key, row, col, NORMAL );
      s_output( avail_func[keys[j].func_index], row, col+31, NORMAL );
   }
}
예제 #9
0
int amx_putchar(int c)
{
  if (createconsole(0, NULL)) {
    if (csry<NUM_LINES && csrx<NUM_COLUMNS) {
      int pos=csry*NUM_COLUMNS+csrx;
      assert(lines!=NULL);
      if (c==__T('\r')) {
        csrx=0;
      } else if (c==__T('\n')) {
        csrx=0;
        csry++;
        if (csry>=NUM_LINES)
          scroll_window(0, -1);
      } else if (c==__T('\b')) {
        if (csrx>0) {
          csrx--;
          pos--;
          lines[pos]=__T(' ');
          //??? lines[pos+1]=attrib;
        } /* if */
      } else {
        lines[pos]=(TCHAR)c;
        //??? lines[pos+1]=attrib;
        csrx++;
        if (csrx>=NUM_COLUMNS && autowrap) {
          csrx=0;
          csry++;
          if (csry>=NUM_LINES)
            scroll_window(0, -1);
        } /* if */
      } /* if */
      refresh_screen(csry,csry+1);
    } /* if */
  } /* if */
  return 1;
}
예제 #10
0
static void
do_movemag(int x, int y)
{
    int xx, yy;

    mag_x = x;
    mag_y = y;
    if (mag_x == new_mag_x && mag_y == new_mag_y)
	globals.ev.flags &= ~EV_MAG_MOVE;
    compute_mag_pos(&xx, &yy);
    XMoveWindow(DISP, magnifier.win, xx, yy);
    scroll_window(&magnifier,
		  (x + mane_base_x) * mane.shrinkfactor - (int)magnifier.width / 2,
		  (y + mane_base_y) * mane.shrinkfactor - (int)magnifier.height / 2);
    draw_ticks(magnifier.width, magnifier.height, globals.gc.ruler);
}
예제 #11
0
void output_char(WINDOW* wnd, unsigned char c) {
    volatile int flag;

    DISABLE_INTR(flag);
    remove_cursor(wnd);
    switch (c) {
        case '\n':
        case 13:
            wnd->cursor_x = 0;
            wnd->cursor_y++;
            break;
        case '\b':
            if (wnd->cursor_x != 0) {
                wnd->cursor_x--;
            } else {
                if (wnd->cursor_y != 0) {
                    wnd->cursor_x = wnd->width - 1;
                    wnd->cursor_y--;
                }
            }
            break;
        case 14:
            poke_screen(wnd->x + wnd->width,
                    wnd->y + wnd->cursor_y,
                    (short unsigned int) 0xB3 | (default_color << 8));
            wnd->cursor_y++;
            break;
        default:
            poke_screen(wnd->x + wnd->cursor_x,
                    wnd->y + wnd->cursor_y,
                    (short unsigned int) c | (default_color << 8));
            wnd->cursor_x++;
            //            if (wnd->cursor_x == wnd->width) {
            //                wnd->cursor_x = 0;
            //                wnd->cursor_y++;
            //            }
            break;
    }
    if (wnd->cursor_y == wnd->height)
        scroll_window(wnd);
    show_cursor(wnd);
    ENABLE_INTR(flag);
}
예제 #12
0
void curses_more()
{
    int height, width;
    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);

    curses_get_window_size(MESSAGE_WIN, &height, &width);
    curses_toggle_color_attr(win, MORECOLOR, NONE, ON);
    mvwprintw(win, my, mx - 1, ">>");
    curses_toggle_color_attr(win, MORECOLOR, NONE, OFF);
    wrefresh(win);
    wgetch(win);
    if (height == 1)
    {
        curses_clear_unhighlight_message_window();
    }
    else
    {
        mvwprintw(win, my, mx - 1, "  ");
        scroll_window(MESSAGE_WIN);
        turn_lines = 1;
    }
}
예제 #13
0
파일: main.c 프로젝트: misfit/dragonfighter
int main (void) {
  /* initialize the game. */
  setup_allegro (MODE, WIDTH, HEIGHT, 16);
  setup_bmps();
  setup_player();
  scrollx = 0;
  scrolly = 0;
  
  currentmap = (MAP*)malloc (sizeof (MAP));
  currentmap->initflag = 1;
  currentmap->idnumber = TCA_13;
    
  map_handler();

  while (!key[KEY_ESC]) {
    get_input();
    move_player();
    scroll_window();
    animate_player();
    map_event_handler();
    map_handler();
    draw_player();
    blit (scrollbmp, bufferbmp, scrollx, scrolly, 0, 0, WIDTH-1, HEIGHT-1);
    print_scroll_debug_messages();
    print_player_debug_messages();

    acquire_screen();
    blit (bufferbmp, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
    release_screen();

    rest (20);
  }
  destroy_bmps();
  allegro_exit();
  return 0;
}
예제 #14
0
int
wscrl(WINDOW *win, int n)
{
int physical = FALSE;
int i;

	T(("wscrl(%x,%d) called", win, n));

	if (! win->_scroll)
		return ERR;

	if (n == 0)
		return OK;

	/* as an optimization, if the scrolling region is the entire screen
	   scroll the physical screen */

	if (   win->_begx == 0 && win->_maxx == columns - 1
	    && !memory_above && !memory_below
	    && ((((win->_begy+win->_regtop == 0 && win->_begy+win->_regbottom == lines - 1)
		  || change_scroll_region)
		 && (   (n < 0 && (parm_rindex || scroll_reverse))
		     || (n > 0 && (parm_index || scroll_forward))
		    )
		) || (win->_idlok && (parm_insert_line || insert_line)
		      && (parm_delete_line || delete_line)
		     )
	       )
	   )
    		physical = TRUE;

	if (physical == TRUE) {
		wrefresh(win);
		scroll_window(curscr, n, win->_begy+win->_regtop, win->_begy+win->_regbottom);
		scroll_window(newscr, n, win->_begy+win->_regtop, win->_begy+win->_regbottom);
	}
	scroll_window(win, n, win->_regtop, win->_regbottom);

	if (physical == TRUE) {
		if (n < 0) {
			if (   ((   win->_begy+win->_regtop == 0
				 && win->_begy+win->_regbottom == lines - 1)
				|| change_scroll_region)
			    && (parm_rindex || scroll_reverse)
			   ) {
				if (change_scroll_region &&
				    (win->_begy+win->_regtop != 0 || win->_begy+win->_regbottom != lines - 1)
				   )
					putp(tparm(change_scroll_region, win->_begy+win->_regtop, win->_begy+win->_regbottom));
				i = abs(n);
				mvcur(-1, -1, win->_begy+win->_regtop, 0);
				if (parm_rindex) {
					putp(tparm(parm_rindex, i));
				} else if (scroll_reverse) {
					while (i--)
						putp(scroll_reverse);
				}
				if (change_scroll_region &&
				    (win->_begy+win->_regtop != 0 || win->_begy+win->_regbottom != lines - 1)
				   )
					putp(tparm(change_scroll_region, 0, lines-1));
			} else {
				i = abs(n);
				if (win->_begy+win->_regbottom < lines - 1) {
					mvcur(-1, -1, win->_begy+win->_regbottom, 0);
					if (parm_delete_line) {
						putp(tparm(parm_delete_line, i));
					} else if (delete_line) {
						while (i--)
							putp(delete_line);
						i = abs(n);
					}
				}
				mvcur(-1, -1, win->_begy+win->_regtop, 0);
				if (parm_insert_line) {
					putp(tparm(parm_insert_line, i));
				} else if (insert_line) {
					while (i--)
						putp(insert_line);
				}
			}
		} else {
			if (   ((   win->_begy+win->_regtop == 0
				 && win->_begy+win->_regbottom == lines - 1)
				|| change_scroll_region)
			    && (parm_index || scroll_forward)
			   ) {
				if (change_scroll_region &&
				    (win->_begy+win->_regtop != 0 || win->_begy+win->_regbottom != lines - 1)
				   )
					putp(tparm(change_scroll_region, win->_begy+win->_regtop, win->_begy+win->_regbottom));
				mvcur(-1, -1, win->_begy+win->_regbottom, 0);
				if (parm_index) {
					putp(tparm(parm_index, n));
				} else if (scroll_forward) {
					i = n;
					while (i--)
						putp(scroll_forward);
				}
				if (change_scroll_region &&
				    (win->_begy+win->_regtop != 0 || win->_begy+win->_regbottom != lines - 1)
				   )
					putp(tparm(change_scroll_region, 0, lines-1));
			} else {
				mvcur(-1, -1, win->_begy+win->_regtop, 0);
				if (parm_delete_line) {
					putp(tparm(parm_delete_line, n));
				} else if (delete_line) {
					i = n;
					while (i--)
						putp(delete_line);
				}
				if (win->_begy+win->_regbottom < lines - 1) {
					mvcur(win->_begy+win->_regtop, 0, win->_begy+win->_regbottom, 0);
					if (parm_insert_line) {
						putp(tparm(parm_insert_line, n));
					} else if (insert_line) {
						i = n;
						while (i--)
							putp(insert_line);
					}
				}
			}
		}

		mvcur(-1, -1, win->_begy+win->_cury, win->_begx+win->_curx);
	} else
	    	touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);

    	return OK;
}
예제 #15
0
void curses_message_win_puts(const char *message, boolean recursed)
{
    int height, width, linespace;
    char *tmpstr;
    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
    boolean border = curses_window_has_border(MESSAGE_WIN);
    int message_length = strlen(message);
    int border_space = 0;
    static long suppress_turn = -1;

    if (strncmp("Count:", message, 6) == 0)
    {
        curses_count_window(message);
        return;
    }
    
    if (suppress_turn == moves)
    {
        return;
    }
    
    curses_get_window_size(MESSAGE_WIN, &height, &width);
    if (border)
    {
        border_space = 1;
        if (mx < 1)
        {
            mx = 1;
        }
        if (my < 1)
        {
            my = 1;
        }
    }
    
    linespace = ((width + border_space) - 3) - mx;
    
    if (strcmp(message, "#") == 0)  /* Extended command or Count: */
    {
        if ((strcmp(toplines, "#") != 0) && (my >= (height - 1 +
         border_space)) && (height != 1)) /* Bottom of message window */
        {
            scroll_window(MESSAGE_WIN);
            mx = width;
            my--;
            strcpy(toplines, message);
        }
        
        return;
    }

    if (!recursed)
    {
        strcpy(toplines, message);
        mesg_add_line((char *) message);
    }
    
    if (linespace < message_length)
    {
        if (my >= (height - 1 + border_space)) /* bottom of message win */
        {
            if ((turn_lines > height) || (height == 1))
            {
                /* Pause until key is hit - Esc suppresses any further
                messages that turn */
                if (curses_more() == '\033')
                {
                    suppress_turn = moves;
                    return;
                }
            }
            else
            {
                scroll_window(MESSAGE_WIN);
                turn_lines++;
            }
        }
        else
        {
            if (mx != border_space)
            {
                my++;
                mx = border_space;
            }
        }
    }

    if (height > 1)
    {
        curses_toggle_color_attr(win, NONE, A_BOLD, ON);
    }
    
    if ((mx == border_space) && ((message_length + 2) > width))
    {
        tmpstr = curses_break_str(message, (width - 2), 1);
        mvwprintw(win, my, mx, "%s", tmpstr);
        mx += strlen(tmpstr);
        if (strlen(tmpstr) < (width - 2))
        {
            mx++;
        }
        free(tmpstr);
        if (height > 1)
        {
            curses_toggle_color_attr(win, NONE, A_BOLD, OFF);
        }
        wrefresh(win);
        curses_message_win_puts(curses_str_remainder(message, (width - 2), 1),
         TRUE);
    }
    else
    {
        mvwprintw(win, my, mx, "%s", message);
        curses_toggle_color_attr(win, NONE, A_BOLD, OFF);
        mx += message_length + 1;
    }
    wrefresh(win);
}
예제 #16
0
파일: cfgkeys.c 프로젝트: eposts/Rich
void master_help( HELP_WINDOW *hw, KEY_DEFS *help, struct screen *help_heading,
                  char *t, int *ch )
{
FILE *fp;               
int col, row, i, j;
int update_name, change_color, draw_page;
char str[80];
char *blank = "                                                 ";
char temp[20];
HELP_WINDOW hw_k;

   xygoto( -1, -1 );
   save_and_draw( hw, help_heading, &w_ptr );
   show_key_def_list( hw, help );

   col = hw->ulft_col + hw->dply_col;
   row = hw->ulft_row + hw->dply_row + hw->v_row;
   change_color = TRUE;
   *ch = 0;
   while (*ch!=F3 && *ch != F10 && *ch!=ESC) {
      draw_page = FALSE;
      position_cursor( hw, hw->line_length, &update_name, &change_color, ch );
      switch (*ch) {
         case PGUP :
            if (hw->select > hw->avail_lines-1) {
               hw->select = hw->select - hw->avail_lines;
               if (hw->v_row > hw->select)
                  hw->select = hw->v_row;
               draw_page = TRUE;
            } else if (hw->select - hw->v_row > 0) {
               hw->select = hw->v_row;
               draw_page = TRUE;
            }
            break;
         case PGDN :
            if (hw->select + hw->avail_lines < hw->num_entries) {
               hw->select = hw->select + hw->avail_lines;
               draw_page = TRUE;
            } else if (hw->select + hw->avail_lines - hw->v_row <
                                                         hw->num_entries) {
               hw->select = hw->num_entries - 1;
               draw_page = TRUE;
            }
            if ((hw->num_entries - 1) - hw->select <
                                              hw->avail_lines && draw_page) {
               i = row - hw->v_row;
               scroll_window( 0, i, col, i+hw->avail_lines-1,
                              col+hw->line_length, NORMAL );
            }
            break;
         case F5 :
            hw_k.dply_col = 2;
            hw_k.dply_row = 3;
            hw_k.line_length = 33;
            hw_k.avail_lines = 6;
            hw_k.v_row = 0;
            hw_k.select = 0;
            hw_k.num_entries = NUM_FUNC;
            hw_k.ulft_col = 20;
            hw_k.ulft_row = row + 1;
            if (hw_k.ulft_row > 12)
               hw_k.ulft_row = row - 12;
            hw_k.total_col = 37;
            hw_k.total_row = 12;
            new_assignment_help( &hw_k, avail_func, func_head, ch );
            if (*ch == RTURN) {
               help[hw->select].key[0] = '*';
               help[hw->select].func_index = (unsigned char)hw_k.select;
               s_output( help[hw->select].key, row, col, cfg.attr );
               s_output( "                     ", row, col+31, cfg.attr );
               s_output( avail_func[help[hw->select].func_index],
                         row, col+31, cfg.attr );
               *ch = 0;
            }
            break;
         case F7 :
            hw_k.ulft_col = 14;
            hw_k.ulft_row = 10;
            hw_k.total_col = 52;
            hw_k.total_row = 5;
            save_and_draw( &hw_k, file_head, &w_ptr );
            xygoto( hw_k.ulft_col+28, hw_k.ulft_row+2 );
            gets( str );
            j = TRUE;
            if ((i = access( str, EXIST )) == 0) {
               s_output( blank, hw_k.ulft_row+2, hw_k.ulft_col+1, NORMAL );
               s_output( "OK to overwrite exiting file (y/n)?",
                          hw_k.ulft_row+2, hw_k.ulft_col+1, NORMAL );
               xygoto( hw_k.ulft_col+38, hw_k.ulft_row+2 );
               i = getkey( );
               while (i != 'Y' && i != 'y' && i != 'N' && i != 'n')
                  i = getkey( );
               if (i == 'n' || i == 'N')
                  j = FALSE;
            }
            xygoto( -1, -1 );
            if (j == TRUE && (fp = fopen( str, "w" )) != NULL) {
               for (i=0; i<hw->num_entries && j; i++) {
                  fprintf( fp, " %22s  = ", help[i].key+3 );
                  fprintf( fp, "  %s\n",  avail_func[help[i].func_index] );
               }
               fclose( fp );
            } else {
               s_output( blank, hw_k.ulft_row+2, hw_k.ulft_col+1, NORMAL );
               s_output( "Cannot open file.  Press any key to contine.",
                          hw_k.ulft_row+2, hw_k.ulft_col+1, NORMAL );
               j = getkey( );
            }
            window_control( &w_ptr, RESTORE, hw_k.ulft_col, hw_k.ulft_row,
                            hw_k.total_col, hw_k.total_row );
            break;
         case F8 :
            if ((fp = fopen( "PRN", "a" )) != NULL) {
               hw_k.ulft_col = 20;
               hw_k.ulft_row = 10;
               hw_k.total_col = 42;
               hw_k.total_row = 5;
               save_and_draw( &hw_k, print_head, &w_ptr );
               j = TRUE;
               for (i=0; i<hw->num_entries && j; i++) {
                  itoa( i+1, temp, 10 );
                  s_output( temp, hw_k.ulft_row+2, hw_k.ulft_col+16, NORMAL );
                  fprintf( fp, " %22s  = ", help[i].key+3 );
                  fprintf( fp, "  %s\n",  avail_func[help[i].func_index] );
                  if (kbhit()) {
                     j = getkey( );
                     if (j == ESC)
                        j = FALSE;
                     else
                        j = TRUE;
                  }
               }
               fprintf( fp, "\f" );
               fclose( fp );
               window_control( &w_ptr, RESTORE, hw_k.ulft_col, hw_k.ulft_row,
                               hw_k.total_col, hw_k.total_row );
            }
            break;
      }
      if (draw_page == TRUE) {
         show_key_def_list( hw, help );
         update_name = TRUE;
         change_color = TRUE;
      }
      row = hw->ulft_row + hw->dply_row + hw->v_row;
      if (update_name) {
         s_output( help[hw->select].key, row, col, NORMAL );
         s_output( avail_func[help[hw->select].func_index], row, col+31,
                      NORMAL );
      }
      if (change_color)
         hlight_line( col, row, hw->line_length, cfg.attr );
      *ch = getkey( );
      change_color = FALSE;
   }
   window_control( &w_ptr, RESTORE, hw->ulft_col, hw->ulft_row,
                   hw->total_col, hw->total_row );
}
예제 #17
0
void curses_message_win_puts(const char *message, boolean recursed)
{
    int height, width, linespace, count;
    char *tmpstr;
    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
    boolean border = curses_window_has_border(MESSAGE_WIN);
    int message_length = strlen(message);
    int border_space = 0;

    if (!recursed)
    {
        strcpy(toplines, message);
        mesg_add_line((char *) message);
    }

    curses_get_window_size(MESSAGE_WIN, &height, &width);
    if (border)
    {
        border_space = 1;
        if (mx < 1)
        {
            mx = 1;
        }
        if (my < 1)
        {
            my = 1;
        }
    }

    linespace = ((width + border_space) - 3) - mx;

    if (linespace < message_length)
    {
        if (my >= (height - 1 + border_space)) /* bottom of message win */
        {
            if (turn_lines == height)
            {
                curses_more();
            }
            else
            {
                scroll_window(MESSAGE_WIN);
                turn_lines++;
            }
        }
        else
        {
            if (mx != border_space)
            {
                my++;
                mx = border_space;
            }
        }
    }

    if (height > 1)
    {
        curses_toggle_color_attr(win, NONE, ATR_BOLD, ON);
    }

    if ((mx == border_space) && ((message_length + 2) > width))
    {
        tmpstr = curses_break_str(message, (width - 2), 1);
        mvwprintw(win, my, mx, tmpstr);
        mx += strlen(tmpstr);
        free(tmpstr);
        if (height > 1)
        {
            curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF);
        }
        wrefresh(win);
        curses_message_win_puts(curses_str_remainder(message, (width - 2), 1),
                                TRUE);
    }
    else
    {
        mvwprintw(win, my, mx, message);
        curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF);
    }
    wrefresh(win);
    mx += message_length + 1;
}
예제 #18
0
파일: cfgkeys.c 프로젝트: eposts/Rich
void new_assignment_help( HELP_WINDOW *hw, char *help[],
                          struct screen *help_heading, int *ch )
{
int col, row, i;
int update_name, change_color, draw_page;

   save_and_draw( hw, help_heading, &w_ptr );
   show_func_list( hw, help );

   col = hw->ulft_col + hw->dply_col;
   row = hw->ulft_row + hw->dply_row + hw->v_row;
   change_color = TRUE;
   *ch = 0;
   while (*ch!=RTURN && *ch!=ESC) {
      draw_page = FALSE;
      position_cursor( hw, hw->line_length, &update_name, &change_color, ch );
      switch (*ch) {
         case PGUP :
            if (hw->select > hw->avail_lines-1) {
               hw->select = hw->select - hw->avail_lines;
               if (hw->v_row > hw->select)
                  hw->select = hw->v_row;
               draw_page = TRUE;
            } else if (hw->select - hw->v_row > 0) {
               hw->select = hw->v_row;
               draw_page = TRUE;
            }
            break;
         case PGDN :
            if (hw->select + hw->avail_lines < hw->num_entries) {
               hw->select = hw->select + hw->avail_lines;
               draw_page = TRUE;
            } else if (hw->select + hw->avail_lines - hw->v_row <
                                                         hw->num_entries) {
               hw->select = hw->num_entries - 1;
               draw_page = TRUE;
            }
            if ((hw->num_entries - 1) - hw->select <
                                              hw->avail_lines && draw_page) {
               i = row - hw->v_row;
               scroll_window( 0, i, col, i+hw->avail_lines-1,
                              col+hw->line_length, NORMAL );
            }
            break;
      }
      if (draw_page == TRUE) {
         show_func_list( hw, help );
         update_name = TRUE;
         change_color = TRUE;
      }
      row = hw->ulft_row + hw->dply_row + hw->v_row;
      if (update_name)
         s_output( help[hw->select], row, col, NORMAL );
      if (change_color)
         hlight_line( col, row, hw->line_length, cfg.attr );
      *ch = getkey( );
      change_color = FALSE;
   }
   window_control( &w_ptr, RESTORE, hw->ulft_col, hw->ulft_row,
                   hw->total_col, hw->total_row );
   if (*ch != RTURN)
      *ch = 0;
}