import std.stdio : readln; import std.string : chomp; import mycurses.mycurses; /*int main(char[][] args) { ushort begin_attr; text_attributes_get(stdout,begin_attr); scope(exit) { exit(begin_attr); } printf("A"); cursor_position_set(stdout,5,10); text_attributes_set(stdout,FGColor.RED | FGColor.BRIGHT | BGColor.RED | BGColor.GREEN | BGColor.BRIGHT | Attr.NEGATIVE); printf("B C"); short x,y; cursor_position_get(stdout,x,y); return 0; } void exit(ushort attr) { text_attributes_set(stdout,attr); }*/ int main(char[][] args) { printf("TEST1"); cursor_position_set(stdout,5,10); printf("TEST2"); short x,y; cursor_position_set(stdout,5,11); printf("C:"); cursor_position_get(stdout,x,y); printf("%d,%d",x,y); return 0; } /+++++ void printExample(uint n,char[] name) { text_attributes_set(stdout,FGColor.RED | FGColor.BRIGHT); printf(" %d)",n); text_attributes_set(stdout,FGColor.GREEN); printf(" %s\n",(name~'\0').ptr); } int main(char[][] args) { ushort beginInfo; version(Windows) { text_attributes_get(stdout,beginInfo); } else version(Linux) { beginInfo = Attr.RESET; } scope(exit) { quit(beginInfo); } char[][] examples = ["Color Table","ASCII Table"]; gete: text_attributes_set(stdout,FGColor.RED | FGColor.GREEN | FGColor.BRIGHT); printf("Available examples:\n"); foreach(i,e; examples) { printExample(i+1,e); } text_attributes_set(stdout,FGColor.GREEN | FGColor.BLUE | FGColor.BRIGHT); printf("Your choice (1-%d): ",examples.length); text_attributes_set(stdout,FGColor.RED | FGColor.BRIGHT); char[] example = chomp(readln()); text_attributes_set(stdout,beginInfo); switch(example) { /** Color Table */ case "1": //ushort[][] arr = [[BGColor.BLACK],[FGColor.RED]]; ushort[][] arr = [[cast(ushort)BGColor.BLACK,BGColor.RED,BGColor.GREEN,BGColor.RED | BGColor.GREEN,BGColor.BLUE,BGColor.RED | BGColor.BLUE,BGColor.GREEN | BGColor.BLUE,BGColor.RED | BGColor.GREEN | BGColor.BLUE], [cast(ushort)FGColor.BLACK,FGColor.RED,FGColor.GREEN,FGColor.RED | FGColor.GREEN,FGColor.BLUE,FGColor.RED | FGColor.BLUE,FGColor.GREEN | FGColor.BLUE,FGColor.RED | FGColor.GREEN | FGColor.BLUE], [cast(ushort)FGColor.BRIGHT,FGColor.BRIGHT | FGColor.RED,FGColor.BRIGHT | FGColor.GREEN,FGColor.BRIGHT | FGColor.RED | FGColor.GREEN,FGColor.BRIGHT | FGColor.BLUE,FGColor.BRIGHT | FGColor.RED | FGColor.BLUE,FGColor.BRIGHT | FGColor.GREEN | FGColor.BLUE,FGColor.BRIGHT | FGColor.RED | FGColor.GREEN | FGColor.BLUE]]; ubyte cursorx = 4; ubyte cursory = 1; cursor_position_set(stdout,0,1); for(uint y=1; y<=16; y++) { printf(" \n"); } cursor_position_set(stdout,0,0); printf(" _ _ _ _ _40 _ _ _41_ _ _ _42 _ _ _ 43_ _ _ 44_ _ _ _45 _ _ _ 46_ _ _ _47 _"); cursor_position_set(stdout,0,1); for(ubyte y=0; y<8; y++) { text_attributes_set(stdout,FGColor.RED | FGColor.GREEN | FGColor.BLUE); cursor_position_set(stdout,0,cursory); printf("%d",30+y); cursor_position_set(stdout,4,cursory); for(ubyte x=0; x<8; x++) { cursor_position_set(stdout,cursorx,cursory); text_attributes_set(stdout,arr[0][x]|arr[1][y]); printf(" Normal "); cursorx += 9; } cursorx = 4; cursory++; for(ubyte x=0; x<8; x++) { cursor_position_set(stdout,cursorx,cursory); text_attributes_set(stdout,arr[0][x]|arr[2][y]); printf(" Bright "); cursorx += 9; } cursorx = 4; cursory++; } break; /** ASCII Table */ case "2": bool specext = 1; char[][256] over; //over.length = 256; over[0..33] = ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS" , "TAB", "LF" , "VT" , "FF" , "CR" , "SO" , "SI" , "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM" , "SUB", "ESC", "FS" , "GS" , "RS" , "US" , "Space"]; over[127] = "DEL"; over[155] = "CSI"; cursor_position_set(stdout,0,0); for(uint i=0; i<4; i++) { text_attributes_set(stdout,BGColor.RED | BGColor.GREEN | BGColor.BLUE); printf(" Dec Hex Oct Char "); if((specext) && (i == 1)) { text_attributes_set(stdout,FGColor.BRIGHT | FGColor.RED | FGColor.GREEN); printf("%c",186); } else { text_attributes_set(stdout,beginInfo); //$$ printf("%c",179); } } text_attributes_set(stdout,beginInfo); //$$ cursor_position_set(stdout,0,1); for(uint i=0; i<4; i++) { for(uint j=0; j<19; j++) { printf("%c",196); } if((specext) && (i == 1)) { text_attributes_set(stdout,FGColor.BRIGHT | FGColor.RED | FGColor.GREEN); printf("%c",215); text_attributes_set(stdout,beginInfo); //$$ } else { printf("%c",197); } } for(uint i=0; i<256; i++) { uint x = 0; uint y = i; while(y >= 64) { x += 20; y -= 64; } cursor_position_set(stdout,x,y+2); text_attributes_set(stdout,FGColor.GREEN); printf(" %3d",i); text_attributes_set(stdout,FGColor.RED | FGColor.GREEN); printf(" %3X",i); text_attributes_set(stdout,FGColor.GREEN | FGColor.BLUE); printf(" %3o",i); text_attributes_set(stdout,FGColor.BRIGHT | FGColor.RED); if(over[i] != null) printf(" %-6s",std.string.toStringz(over[i])); else printf(" %-6c",i); if((specext) && (x == 20)) { text_attributes_set(stdout,FGColor.BRIGHT | FGColor.RED | FGColor.GREEN); printf("%c",186); text_attributes_set(stdout,beginInfo); //$$ } else { text_attributes_set(stdout,beginInfo); //$$ printf("%c",179); } } break; default: text_attributes_set(stdout,FGColor.BRIGHT | FGColor.RED); printf("\nExample does not exist!\n\n"); goto gete; } return 0; } void quit(int h) { text_attributes_set(stdout,h); } +++++/