-Added prints() function, fixes #1132, #1859

-Tabs work inside built-in log window, fixes #1867
This commit is contained in:
Juan Linietsky 2015-05-09 18:09:58 -03:00
parent 1310e09c73
commit 65d48d6d39
4 changed files with 36 additions and 1 deletions

View file

@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
"str", "str",
"print", "print",
"printt", "printt",
"prints",
"printerr", "printerr",
"printraw", "printraw",
"var2str", "var2str",
@ -561,6 +562,22 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
r_ret=Variant(); r_ret=Variant();
} break;
case TEXT_PRINT_SPACED: {
String str;
for(int i=0;i<p_arg_count;i++) {
if (i)
str+=" ";
str+=p_args[i]->operator String();
}
//str+="\n";
print_line(str);
r_ret=Variant();
} break; } break;
case TEXT_PRINTERR: { case TEXT_PRINTERR: {
@ -1251,6 +1268,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type=Variant::NIL; mi.return_val.type=Variant::NIL;
return mi; return mi;
} break;
case TEXT_PRINT_SPACED: {
MethodInfo mi("prints",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::NIL,"..."));
mi.return_val.type=Variant::NIL;
return mi;
} break; } break;
case TEXT_PRINTERR: { case TEXT_PRINTERR: {

View file

@ -84,6 +84,7 @@ public:
TEXT_STR, TEXT_STR,
TEXT_PRINT, TEXT_PRINT,
TEXT_PRINT_TABBED, TEXT_PRINT_TABBED,
TEXT_PRINT_SPACED,
TEXT_PRINTERR, TEXT_PRINTERR,
TEXT_PRINTRAW, TEXT_PRINTRAW,
VAR_TO_STR, VAR_TO_STR,

View file

@ -1036,7 +1036,7 @@ void GDTokenizerText::advance(int p_amount) {
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
#define BYTECODE_VERSION 3 #define BYTECODE_VERSION 4
Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) { Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) {

View file

@ -235,6 +235,9 @@ if (m_height > line_height) {\
while (c[end]!=0 && !(end && c[end-1]==' ' && c[end]!=' ')) { while (c[end]!=0 && !(end && c[end-1]==' ' && c[end]!=' ')) {
int cw = font->get_char_size(c[end],c[end+1]).width; int cw = font->get_char_size(c[end],c[end+1]).width;
if (c[end]=='\t') {
cw=tab_size*font->get_char_size(' ').width;
}
w+=cw; w+=cw;
if (c[end]==' ') { if (c[end]==' ') {
@ -292,6 +295,9 @@ if (m_height > line_height) {\
int cw=font->get_char_size(c[i],c[i+1]).x; int cw=font->get_char_size(c[i],c[i+1]).x;
if (c[i]=='\t') {
cw=tab_size*font->get_char_size(' ').width;
}
if (p_click_pos.x-cw/2>pofs) { if (p_click_pos.x-cw/2>pofs) {
@ -332,6 +338,10 @@ if (m_height > line_height) {\
cw=font->draw_char(ci,Point2(pofs,y+lh-(fh-ascent)),c[i],c[i+1],color); cw=font->draw_char(ci,Point2(pofs,y+lh-(fh-ascent)),c[i],c[i+1],color);
} }
if (c[i]=='\t') {
cw=tab_size*font->get_char_size(' ').width;
}
//print_line("draw char: "+String::chr(c[i])); //print_line("draw char: "+String::chr(c[i]));