コード例 #1
0
ファイル: console.c プロジェクト: anders1556/GridOS
static unsigned int get_line_idx(unsigned int current_idx)
{
	unsigned int line_idx;
	char* line_idx_addr;
	char* c;
	int i;

	c = (char*)&line_idx;
	for (i = 0; i < sizeof(unsigned int); i++)
	{
		line_idx_addr = get_idx_addr_in_buf(current_idx);
		*c = *line_idx_addr;
		current_idx = get_buf_idx(current_idx + 1);
		c++;
	}

	return line_idx;
}
コード例 #2
0
ファイル: console.c プロジェクト: anders1556/GridOS
static inline void set_line_next_idx(unsigned int next_line_idx_idx, unsigned int line_idx)
{
	int i = 0;
	char *c;
	
	
	c = (char*)&line_idx;

	for (i = 0; i < sizeof(unsigned int); i++ )
	{		
		char* idx_addr = get_idx_addr_in_buf(next_line_idx_idx);
		*idx_addr = *c;
		next_line_idx_idx = get_buf_idx(next_line_idx_idx + 1);
		c++;
	}		

	return;
}
コード例 #3
0
ファイル: console.c プロジェクト: LastRitter/GridOS
/* 向屏幕打印缓存中的字符 */
static int draw_a_line(unsigned int* pos_x, unsigned int* pos_y, unsigned int start, unsigned int end)
{
	u16 gbk_code;
	unsigned char *c, *byte2;	
	int lf = 0;
	int count = 0;

	unsigned int p_string	= get_buf_idx(start);
	unsigned int color		= dsp_ctx.color;
	unsigned int cur_x		= *pos_x;
	unsigned int cur_y		= *pos_y;
	

	/* Disable the cursor while we are drawing */
	console_cursor_toggle(false);

	while (p_string != end)  
	{

		//c = *p_string;
		c = (unsigned char*)get_idx_addr_in_buf(p_string);

		if (*c == ' ')
		{
			cur_x += DOTFNT_CHAR_SPACE_LEN;			
			p_string = get_buf_idx(p_string + 1);			
		}
		else if (*c == '\n')
		{
			cur_x = 0;
			lf = 1;
			p_string = get_buf_idx(p_string + 1);
		}		
		else if (*c == 0xd)
		{
			p_string = get_buf_idx(p_string + 1);
			//cur_x = 0;			
		}
		else if (*c == 0x09/*tab*/)
		{
			p_string = get_buf_idx(p_string + 1);
			cur_x |= 31;
			cur_x++;
		}
		/* English is 1 byte */
		else if (*c >= 33 && *c < 127)
		{			
			cur_x += draw_eng_char(*c, cur_x, cur_y, color);
			p_string = get_buf_idx(p_string + 1);	
		}
		/*127退格键,27四个方向键,131-138,255是F3-10 F12,140是F11*/
		else if (*c == 127 || *c == 27 || *c == 131 ||
			*c == 255 || *c == 132 || *c == 133 || 
			*c == 134 || *c == 135 || *c == 136 || 
			*c == 137 || *c == 138 || *c == 140){
			p_string = get_buf_idx(p_string + 1);/*+1 就是跳过他们,这些过滤的键,直接跳过,就不绘制了*/
		}
		/* Chinese is 2 bytes */
		else
		{
			byte2 = get_idx_addr_in_buf(get_buf_idx(p_string + 1));
			gbk_code = (*c << 8) | (*byte2);			
			cur_x += draw_gbk_chinese(gbk_code, cur_x, cur_y, color);			
			p_string = get_buf_idx(p_string + 2);
		}

		/* Modify position,check overflow */
		if (cur_x + DOTFNT_ENG_CHAR_WIDTH >= dsp_ctx.max_x)
		{
			cur_x = 0;		
		}
		if (cur_x == 0)			/* 已经打印完一行(屏幕),退出 */
		{										
			cur_y += DOTFNT_CHAR_LINE_HEIGHT;
			break;
		}		
	}

	*pos_x = cur_x;
	*pos_y = cur_y;

	/* Set the cursor position before enable cursor */
	console_cursor_move(cur_x, cur_y);
	console_cursor_toggle(true);

	count = get_buf_length(start, p_string);
	/* 遇到\n,需要跨过缓存中保存的index */
	if (lf)
	{
		count += 2 * sizeof(unsigned int);
	}
	
	return count;
}