Exemplo n.º 1
0
//-----------------------------------------------------------------------------
void graphics::clear_screen()
{
	set_cursor_pos(1, console_size.Y);
	for (int i = 0; i < console_size.Y; i++)
		cout << '\n';
	set_cursor_pos(1, 1);
}
Exemplo n.º 2
0
/*** AG Link finder, to work with TAB key ***/
void FindNextLink( struct scrpos *inf, char dir )
{
	AGNode src = (AGNode) inf->node;

	/* If there was a previous active link, reset styles */
	if( src->ActiveLink )
		src->ActiveLink->bgpen = DEF_BGPEN,
		src->ActiveLink->style = DEF_LINKSTYLE;

	/* If there is no previous selected link, or it is now outside **
	** the visible area, choose a new one, starting from topline.  */
	if( src->ActiveLink == NULL || src->ActiveLine < src->line ||
	    src->ActiveLine >= src->line+inf->height-1 )
	{
		short nb;
		src->ActiveLink = WordsPara( src->StartLine = src->Shown );
		src->ActiveLine = src->line;
		/* Start at bottom of screen, if backward scan */
		if( dir == -1 )
		{
			for(nb=inf->height-2; nb && NEXT(src->StartLine);
			    nb--,src->StartLine=NEXT(src->StartLine),src->ActiveLine++);
			src->ActiveLink = EndOfLine( src->StartLine );
		}
			
	} else {
		/* Unhilight previous visible link */
		tabs = src->StartLine->ts;
		set_cursor_pos(src->ActiveLine - src->line + 1, 0);
		RenderLine(src->StartLine, src->column, inf->width, OVERWRITE);
		NextLink( src, dir );
	}

	/* Search for the next available link following current position */
	while( src->StartLine )
	{
		AGWord wrd = src->ActiveLink;
		if(wrd && wrd->data != NULL && wrd->link) break;
		NextLink( src, dir );
		/* If `cursor' go outside visible area, resets it */
		if( src->ActiveLine >= src->line + inf->height - 1 ||
		    src->ActiveLine <  src->line )
		{
			src->ActiveLink = NULL;
			break;
		}
	}
	/* Hilite the new one */
	if( src->ActiveLink )
	{
		src->ActiveLink->bgpen = DEF_ACTIVELINK;
		src->ActiveLink->style = DEF_LINKSTYLE | FSF_INVERSID;

		tabs = src->StartLine->ts;
		set_cursor_pos(src->ActiveLine - src->line + 1, 0);
		RenderLine(src->StartLine, src->column, inf->width, OVERWRITE);
	}
	set_cursor_pos(inf->height,6);
	fflush(stdout);
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
void graphics::show_time(const tm* lcTime, int line_no)
{
	const int SIZE = 50;
	int length;
	int xCo;
	char memBuff[SIZE];
	ostrstream oMemBuff(memBuff, SIZE);
	oMemBuff << dayOfWeek[lcTime->tm_wday] << ", " << lcTime->tm_mday << ' '
		<< months[lcTime->tm_mon] << ' ' << lcTime->tm_year + 1900 << ". ";
	if(lcTime->tm_hour < 10)
		oMemBuff << '0' << lcTime->tm_hour << " : ";
	else
		oMemBuff << lcTime->tm_hour << " : ";
	if(lcTime->tm_min < 10)
		oMemBuff << '0' << lcTime->tm_min << " : ";
	else
		oMemBuff << lcTime->tm_min << " : ";
	if(lcTime->tm_sec < 10)
		oMemBuff << '0' << lcTime->tm_sec;
	else
		oMemBuff << lcTime->tm_sec;
	oMemBuff << '\0';
	length = strlen(memBuff);
	xCo = (console_size.X - length) / 2;
	set_cursor_pos(1, line_no);
	clear_line();
	set_cursor_pos(xCo, line_no);
	cout << memBuff;
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void clear_screen()
   {
   set_cursor_pos(1, 25);
   for(int j=0; j<25; j++)
      putch('\n');
   set_cursor_pos(1, 1);
   }
Exemplo n.º 5
0
//--------------------------------------------------------------
void building::show_floor_reqs() const  //display floor requests
   {
   for(int j=0; j<NUM_FLOORS; j++)
      {
      set_cursor_pos(SPACING, NUM_FLOORS-j);
      if(floor_request[UP][j]==true)
         cout << '\x1E';             //up arrow
      else
         cout << ' ';
      set_cursor_pos(SPACING+3, NUM_FLOORS-j);
      if(floor_request[DN][j]==true)
         cout << '\x1F';             //down arrow
      else
         cout << ' ';
      }
   }  //end show_floor_reqs()
Exemplo n.º 6
0
void torrent_view::render()
{
	print_tabs();
	print_headers();

	int lines_printed = header_size;

	int torrent_index = 0;

	for (std::vector<lt::torrent_status const*>::iterator i = m_filtered_handles.begin();
		i != m_filtered_handles.end(); ++torrent_index)
	{
		if (torrent_index < m_scroll_position)
		{
			++i;
			continue;
		}
		if (lines_printed >= m_height)
			break;

		lt::torrent_status const& s = **i;
		if (!s.handle.is_valid())
		{
			i = m_filtered_handles.erase(i);
			continue;
		}
		++i;

		set_cursor_pos(0, torrent_index + header_size - m_scroll_position);
		print_torrent(s, torrent_index == m_active_torrent);
		++lines_printed;
	}

	clear_rows(torrent_index + header_size, m_height);
}
Exemplo n.º 7
0
static int console_height() {
  static int console_height = -1;

  if (console_height == -1) {
    /* determine the height of the console */
    int curstartrow, curstartcol;
    get_cursor_pos(&curstartrow, &curstartcol);
    console_height = 0;
    while ( set_cursor_pos(console_height, 0) == 0 ) {
      console_height++;
    }
    set_cursor_pos( curstartrow, curstartcol );

  }

  return console_height;
}
Exemplo n.º 8
0
Arquivo: vga.c Projeto: jo-va/toutatis
void vga_clear()
{
        uint16_t i;
        for (i = 0; i < COLS * ROWS; ++i) {
                video_mem[i] = (uint8_t)' ' | attribute;
        }
        xpos = ypos = 0;
        set_cursor_pos(0, 0);
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void draw_circle(int xC, int yC, int radius)
   {
   double theta, increment, xF, pi=3.14159;
   int x, xN, yN;

   increment = 0.8 / static_cast<double>(radius);
   for(theta=0; theta<=pi/2; theta+=increment)  //quarter circle
      {
      xF = radius * cos(theta);  
      xN = static_cast<int>(xF * 2 / 1); //pixels not square
      yN = static_cast<int>(radius * sin(theta) + 0.5);
      x = xC-xN;
      while(x <= xC+xN)          //fill two horizontal lines
         {                       //one for each half circle
         set_cursor_pos(x,   yC-yN); putch(fill_char);  //top
         set_cursor_pos(x++, yC+yN); putch(fill_char);  //bottom
         }
      }  //end for
   }
Exemplo n.º 10
0
void *update(void *ignored)
{

	while(1)
		{
			/** await for a request to update the world **/
			waitUpdate();

       if(goFlag)
        return (void *)UPDATE_EXIT_CODE;

			//lprintf("updateThread: ping!");
			/** request received; re-draw the world **/
			mutex_lock(&worldLock);
			
			/* draw the target */
			set_cursor_pos(GAMEBAR_ROW, oldTargetPos);
			print(1, GAMEBAR_BAR);
			set_cursor_pos(GAMEBAR_ROW, targetPos);
			print(1, GAME_TARGET);
			oldTargetPos=targetPos;

			/* draw the player */
			set_cursor_pos(P1_ROW, oldP1Cursor);
			print(1, ERASE_CURSOR);
			set_cursor_pos(P1_ROW, p1Cursor);
			print(1, GAME_CURSOR);
			oldP1Cursor=p1Cursor;

			/* draw the score */
			set_cursor_pos(22,0);
			printf("Score: %d\n",p1Score);
			
		
			
			/** unlock world **/
			mutex_unlock(&worldLock);

     
      
			yield(-1);
		}
}
Exemplo n.º 11
0
//--------------------------------------------------------------
void elevator::dests_display() const //display destinations
   {                                 //   selected by buttons
   for(int j=0; j<NUM_FLOORS; j++)   //   inside the car
      {
      set_cursor_pos(SPACING-2+(car_number+1)*SPACING, NUM_FLOORS-j);
      if( destination[j] == true )
         cout << '\xFE';             //small box
      else
         cout << ' ';                //blank
      }
   }  //end dests_display()
Exemplo n.º 12
0
void LineEdit::set_cursor_at_pixel_pos(int p_x) {

Ref<Font> font = get_font("font");
int ofs = window_pos;
Ref<StyleBox> style = get_stylebox("normal");
int pixel_ofs = 0;
Size2 size = get_size();

switch (align) {

case ALIGN_FILL:
case ALIGN_LEFT: {

    pixel_ofs = int(style->get_offset().x);
}
break;
case ALIGN_CENTER: {

    pixel_ofs=int(size.width-(cached_width))/2;
}
break;
case ALIGN_RIGHT: {

    pixel_ofs=int(size.width-style->get_offset().x-(cached_width));
}
break;
}


while (ofs<text.length()) {

    int char_w = 0;
    if (font != NULL) {
        char_w = font->get_char_size(text[ofs]).width;
    }
    pixel_ofs+=char_w;

    if (pixel_ofs > p_x) { //found what we look for
        break;
    }


    ofs++;
}

set_cursor_pos( ofs );

/*
int new_cursor_pos=p_x;
int charwidth=draw_area->get_font_char_width(' ',0);
new_cursor_pos=( ( (new_cursor_pos-2)+ (charwidth/2) ) /charwidth );
if (new_cursor_pos>(int)text.length()) new_cursor_pos=text.length();
set_cursor_pos(window_pos+new_cursor_pos); */
}
Exemplo n.º 13
0
//--------------------------------------------------------------
void elevator::car_display()         //display elevator image
   {
   set_cursor_pos(SPACING+(car_number+1)*SPACING, NUM_FLOORS-old_floor);
   cout << "   ";                    //erase old position
   set_cursor_pos(SPACING-1+(car_number+1)*SPACING,
                                      NUM_FLOORS-current_floor);
   switch(loading_timer)
      {
      case 3:
         cout << "\x01\xDB \xDB ";   //draw car with open door
         break;                      //happy face on left
      case 2:
         cout << " \xDB\x01\xDB ";   //happy face in open door
         get_destinations();         //get destinations
         break;
      case 1:
         cout << " \xDB\xDB\xDB ";   //draw with closed door
         break;                      //no happy face
      case 0:
         cout << " \xDB\xDB\xDB ";   //closed door, no
         break;                      //happy face (default)
      }
   set_cursor_pos(SPACING+(car_number+1)*SPACING,
                                    NUM_FLOORS-current_floor);
   switch(unloading_timer)
      {
      case 3:
         cout << "\xDB\x01\xDB ";    //draw car with open door
         break;                      //happy face in car
      case 2:
         cout << "\xDB \xDB\x01";    //draw car with open door
         break;                      //happy face on right
      case 1:
         cout << "\xDB\xDB\xDB ";    //draw with closed door
         break;                      //no happy face
      case 0:
         cout << "\xDB\xDB\xDB ";    //closed door, no
         break;                      //happy face (default)
      }
   old_floor = current_floor;        //remember old floor
   }  //end car_display()
Exemplo n.º 14
0
//-----------------------------------------------------------------------------
void graphics::draw_box(int xCo, int yCo, int width, int height)
{
	int i;
	set_cursor_pos(xCo, yCo);
	cout << TOP_LEFT_CORNER;
	for(i = 1; i < width; i++)
		cout << HORIZ_LINE;
	cout << TOP_RIGHT_CORNER;
	for(i = 1; i < height; i++)
	{
		set_cursor_pos(xCo, yCo + i);
		cout << VERT_LINE;
		set_cursor_pos(xCo + width, yCo + i);
		cout << VERT_LINE;
	}
	set_cursor_pos(xCo, yCo + height);
	cout << BOTTOM_LEFT_CORNER;
	for(i = 1; i < width; i++)
		cout << HORIZ_LINE;
	cout << BOTTOM_RIGHT_CORNER;
}
Exemplo n.º 15
0
void clear_screen(void)
{
	u32 w, h;
	vid_drv->get_text_resolution(&w, &h);

	int x, y;
	for (y=0; y<h; y++)
		for (x=0; x<w; x++)
			vid_drv->putchar((7 << 8) | ' ', x, y);
	
	set_cursor_pos(0, 0);
}
Exemplo n.º 16
0
Arquivo: joyme.c Projeto: cjxgm/clabs
int main(int argc,char * argv[])
{
	int fd;
	int getnum;
	int success;
	struct js_event e;

	fd = open(argv[1], O_RDONLY);
	if (fd == -1) {
		fprintf(stderr, "error: joystick open failed!\n");
		return 1;
	}

    if (!(display = XOpenDisplay(NULL))) {
        fprintf(stderr, "Cannot open local X-display.\n");
        return;
    }
    root = DefaultRootWindow(display);

	set_cursor_pos(0, 0);

	while (1) {
		read(fd, &e, sizeof(struct js_event));
		printf("value:%d type:%d number:%d\n", e.value, e.type, e.number);
		if (e.type == 2) {
			if (e.number == 0) {	// Left-Right
				if (e.value > 0) {
					int x, y;
					get_cursor_pos(&x, &y);
					x += 10;
					set_cursor_pos(x, y);
				}
				else if (e.value < 0){
				}
			}
		}
	}

	return 0;
}
Exemplo n.º 17
0
//--------------------------------------------------------------
//record_floor_reqs() -- get requests from riders outside car
void building::record_floor_reqs()
   {
   char ch = 'x';             //utility char for input
   char ustring[BUF_LENGTH];  //utility string for input
   int iFloor;                //floor from which request made
   char chDirection;          //'u' or 'd' for up or down
   
   set_cursor_pos(1,22);      //bottom of screen
   cout << "Press [Enter] to call an elevator: ";
   if( !kbhit() )             //wait for keypress (must be CR)
      return;
   cin.ignore(10, '\n');
   if(ch=='\x1B')             //if escape key, end program
      exit(0);
   set_cursor_pos(1,22); clear_line();  //clear old text
   set_cursor_pos(1,22);      //bottom of screen
   cout << "Enter the floor you're on: ";
   cin.get(ustring, BUF_LENGTH);        //get floor
   cin.ignore(10, '\n');      //eat chars, including newline
   iFloor = atoi(ustring);    //convert to integer

   cout << "Enter direction you want to go (u or d): ";
   cin.get(chDirection);      //(avoid multiple linefeeds)
   cin.ignore(10, '\n');      //eat chars, including newline

   if(chDirection=='u' || chDirection=='U')
      floor_request[UP][iFloor-1] = true;  //up floor request
   if(chDirection=='d' || chDirection=='D')
      floor_request[DN][iFloor-1] = true;  //down floor request
   set_cursor_pos(1,22); clear_line();     //clear old text
   set_cursor_pos(1,23); clear_line();
   set_cursor_pos(1,24); clear_line();
   }  //end record_floor_reqs()
Exemplo n.º 18
0
void initScreen(void)
{
	int i;
	for(i=0; i<24; i++)
	printf("                                                                                ");
	set_cursor_pos(GAMEBAR_ROW, 3);
	print(1,"<");
	for(i=0; i<74; i++)
		{
			print(1, GAMEBAR_BAR);
		}
	print(1,">");
}
Exemplo n.º 19
0
void print_info_init(uint8_t y){
	asm volatile(
	"movw %%ds, %0"
	:"=a"(ds_offset)
	);
	info_x=0;
	info_y=y;
	set_cursor_pos(info_x, info_y);
	/*один раз выводим информацию, дальше меняется только цвет*/
	print(info_str);
	info_color=BLACK;
	tick_counter=0;
}
Exemplo n.º 20
0
void torrent_view::arrow_up()
{
	if (m_filtered_handles.empty()) return;
	if (m_active_torrent <= 0) return;

	if (m_active_torrent - 1 < m_scroll_position)
	{
		--m_active_torrent;
		m_scroll_position = m_active_torrent;
		TORRENT_ASSERT(m_scroll_position >= 0);
		render();
		return;
	}

	set_cursor_pos(0, header_size + m_active_torrent - m_scroll_position);
	print_torrent(*m_filtered_handles[m_active_torrent], false);
	--m_active_torrent;
	TORRENT_ASSERT(m_active_torrent >= 0);

	set_cursor_pos(0, header_size + m_active_torrent - m_scroll_position);
	print_torrent(*m_filtered_handles[m_active_torrent], true);
}
Exemplo n.º 21
0
//--------------------------------------------------------------
void draw_pyramid(int x1, int y1, int height)
   {
   int x, y;
   for(y=y1; y<y1+height; y++)
      {
      int incr = y - y1;
      for(x=x1-incr; x<=x1+incr; x++)
         {
         set_cursor_pos(x, y);
         putch(fill_char);
         }
      }
   }
Exemplo n.º 22
0
//--------------------------------------------------------------
void draw_line(int x1, int y1, int x2, int y2)
   {

   int w, z, t, w1, w2, z1, z2;
   double xDelta=x1-x2, yDelta=y1-y2, slope;
   bool isMoreHoriz;

   if( fabs(xDelta) > fabs(yDelta) ) //more horizontal
      {
      isMoreHoriz = true;
      slope = yDelta / xDelta;
      w1=x1; z1=y1; w2=x2, z2=y2;    //w=x, z=y 
      }
   else                              //more vertical
      {
      isMoreHoriz = false;
      slope = xDelta / yDelta;
      w1=y1; z1=x1; w2=y2, z2=x2;    //w=y, z=x
      }

   if(w1 > w2)                       //if backwards w
      {
      t=w1; w1=w2; w2=t;             //   swap (w1,z1)
      t=z1; z1=z2; z2=t;             //   with (w2,z2)
      }
   for(w=w1; w<=w2; w++)            
      {
      z = static_cast<int>(z1 + slope * (w-w1));
      if( !(w==80 && z==25) )        //avoid scroll at 80,25
         {
         if(isMoreHoriz)
            set_cursor_pos(w, z);
         else
            set_cursor_pos(z, w);
         putch(fill_char);
         }
      }
   }
Exemplo n.º 23
0
int main()
   {
   init_graphics();           //initialize graphics system

   circle cir(40, 12, 5, cBLUE, X_FILL);      //create circle
   rect rec(12, 7, 10, 15, cRED, SOLID_FILL); //create rectangle
   tria tri(60, 7,  11, cGREEN, MEDIUM_FILL); //create triangle

   cir.draw();                //draw all shapes
   rec.draw();
   tri.draw();
   set_cursor_pos(1, 25);     //lower left corner
   return 0;
   }
Exemplo n.º 24
0
void torrent_view::arrow_down()
{
	if (m_filtered_handles.empty()) return;
	if (m_active_torrent >= int(m_filtered_handles.size()) - 1) return;

	int bottom_pos = m_height - header_size - 1;
	if (m_active_torrent - m_scroll_position + 1 > bottom_pos)
	{
		++m_active_torrent;
		m_scroll_position = m_active_torrent - bottom_pos;
		TORRENT_ASSERT(m_scroll_position >= 0);
		render();
		return;
	}

	set_cursor_pos(0, header_size + m_active_torrent - m_scroll_position);
	print_torrent(*m_filtered_handles[m_active_torrent], false);

	TORRENT_ASSERT(m_active_torrent >= 0);
	++m_active_torrent;

	set_cursor_pos(0, header_size + m_active_torrent - m_scroll_position);
	print_torrent(*m_filtered_handles[m_active_torrent], true);
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void draw_rectangle(int left, int top, int right, int bottom) 
   {
   char temp[80];
   int width = right - left + 1;

   for(int j=0; j<width; j++)      //string of squares
      temp[j] = fill_char;   
   temp[j] = 0;                    //null

   for(int y=top; y<=bottom; y++)  //stack of strings 
      {
      set_cursor_pos(left, y);
      cputs(temp);
      }
   }
Exemplo n.º 26
0
int main( int argc, char *argv[] )
{
    int i, err;

    switch(argc) {
        case 6:
            i = atoi(argv[5]);
            if(i >= 0)
                bad_sleep = i;
        case 5:
            i = atoi(argv[4]);
            if(i >= 0)
                pause = i;
        case 4:
            i = atoi(argv[3]);
            if(i > 0)
                sems = i;
        case 3:
            i = atoi(argv[2]);
            if(i <= 26 && i > 0)
                run = i;
        case 2:
            i = atoi(argv[1]);
            if(i > 1 || i <= 24)
                threads = i;
        default:
            break;
    }

    expect(thr_init(STACK_SIZE));
    expect(mutex_init(&lock_print));
    expect(mutex_init(&lock_running));
    expect(sem_init(&sem, sems));

    for(i=0; i<80; i++)
        empty[i] = ' ';
    empty[80] = '\0';
   
    expect(thr_create(bad, (void*)i) >= 0);
    
    for(i=0; i<threads; i++)
        expect(thr_create(race, (void*)i) >= 0);
    
    getchar();
    expect(set_cursor_pos(24,0));
    
    task_vanish(0);
}
Exemplo n.º 27
0
void torrent_view::print_headers()
{
	set_cursor_pos(0, 1);

	char str[400];

	// print title bar for torrent list
	snprintf(str, sizeof(str)
		, " %-3s %-50s %-35s %-17s %-17s %-11s %-6s %-6s %-4s\x1b[K"
		, "#", "Name", "Progress", "Download", "Upload", "Peers (D:S)"
		, "Down", "Up", "Flags");

	if (m_width + 1 < int(sizeof(str)))
		str[m_width + 1] = '\0';

	print(str);
}
Exemplo n.º 28
0
int main()
{
  init_graphics(); // initialize graphics system

  circle c1; // create circles
  circle c2; 
  circle c3;

  c1.set(15, 7, 5, cBLUE, X_FILL); // set circle attributes
  c2.set(41, 12, 7, cRED, O_FILL);
  c3.set(65, 18, 4, cGREEN, MEDIUM_FILL);

  c1.draw(); // draw circles
  c2.draw();
  c3.draw();
  set_cursor_pos(1, 25); // lower left corner
  return 0;
}
Exemplo n.º 29
0
void debug_view_memory::view_notify(debug_view_notification type)
{
	if (type == VIEW_NOTIFY_CURSOR_CHANGED)
	{
		// normalize the cursor
		set_cursor_pos(get_cursor_pos(m_cursor));
	}
	else if (type == VIEW_NOTIFY_SOURCE_CHANGED)
	{
		// update for the new source
		const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
		m_chunks_per_row = m_bytes_per_chunk * m_chunks_per_row / source.m_prefsize;
		m_bytes_per_chunk = source.m_prefsize;
		if (source.m_space != NULL)
			m_expression.set_context(&source.m_space->device().debug()->symtable());
		else
			m_expression.set_context(NULL);
	}
}
Exemplo n.º 30
0
void torrent_view::print_tabs()
{
	set_cursor_pos(0, 0);

	char str[400];
	int pos = 0;
	char const* filter_names[] = { "all", "downloading", "non-paused"
		, "seeding", "queued", "stopped", "checking", "loaded"};
	for (int i = 0; i < int(sizeof(filter_names)/sizeof(filter_names[0])); ++i)
	{
		pos += snprintf(str+ pos, sizeof(str) - pos, "%s[%s]%s"
			, m_torrent_filter == i?esc("7"):""
			, filter_names[i], m_torrent_filter == i?esc("0"):"");
	}
	pos += snprintf(str + pos, sizeof(str) - pos, "\x1b[K");

	if (m_width + 1 < int(sizeof(str)))
		str[m_width + 1] = '\0';
	print(str);
}