
unit Text
{
	public const uint16 ID = 0;
	
	//---------------------------------------------------
	//[i] linkinterface_char char;
	link unit char {}
	
	[int8*11] number_buffer;
	
	//[i] var_bool lock_low;
	public bool lock_low;
	
	//---------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		lock_low = true;
	}
	//---------------------------------------------------
	//[i] function_void clear;
	public void clear()
	{
		char.clear();
	}
	//---------------------------------------------------
	//[i] function_void clear_line int32;
	public void clear_line( int32 line )
	{
		char.clear_line( line );
	}
	//---------------------------------------------------
	//[i] function_void show_text int32 int32 Cstring;
	public void show_text( int32 line, int32 column, [int8*?] string )
	{
		int16 i = 0;
		forever {
			int8 ch = string[i];
			if( ch == 0 ) return;
			char.write_char( line, column, ch );
			column + char.PerWidth;
			i + 1;
		}
	}
	//---------------------------------------------------
	//[i] function_void show_number int32 int32 int32;
	public void show_number( int32 line, int32 column, int32 data0 )
	{
		//计算正负数
		bool isNeg;
		uint32 data;
		if( data0 >= 0 ) {
			data = (uint)data0;
			isNeg = false;
		} else {
			data = (uint)-data0;
			isNeg = true;
		}
		//解析数字到缓冲区中
		int16 i = 0;
		forever {
			int8 ch = '0' + (int)(uint8)(uint16)(data % 10);
			number_buffer[i] = ch;
			i + 1;
			data / 10;
			if( data == 0 ) {
				if( isNeg ) {
					number_buffer[i] = '-';
					i + 1;
				}
				break;
			}
		}
		//显示缓冲区中的字符到屏幕上
		if( !lock_low ) column + (i - 1);
		int16 j = 0;
		loop( i ) {
			int8 ch = number_buffer[j];
			char.write_char( line, column, ch );
			j + 1;
			column - char.PerWidth;
		}
	}
}






