3 * Summary: Functions that any display port needs to implement.
4 * Written by: M.Itakura
19 #include "tilereg-text.h"
25 #include "tiledef-main.h"
28 #include "windowmanager.h"
35 void set_mouse_enabled(bool enabled
)
37 crawl_state
.mouse_enabled
= enabled
;
40 void gui_init_view_params(crawl_view_geometry
&geom
)
42 // The tile version handles its own layout on a pixel-by-pixel basis.
43 // Pretend that all of the regions start at character location (1,1).
69 int putch(unsigned char chr
)
72 TextRegion::text_mode
->putch(chr
);
76 int putwch(unsigned chr
)
78 // No unicode support.
79 putch(static_cast<unsigned char>(chr
));
83 void writeWChar(unsigned char *ch
)
86 TextRegion::text_mode
->writeWChar(ch
);
89 void clear_to_end_of_line()
92 TextRegion::text_mode
->clear_to_end_of_line();
95 int cprintf(const char *format
,...)
97 char buffer
[2048]; // One full screen if no control seq...
99 va_start(argp
, format
);
100 vsnprintf(buffer
, sizeof(buffer
), format
, argp
);
103 TextRegion::text_mode
->addstr(buffer
);
107 void textcolor(int color
)
109 TextRegion::textcolor(color
);
112 void textbackground(int bg
)
114 TextRegion::textbackground(bg
);
117 void set_cursor_enabled(bool enabled
)
120 TextRegion::_setcursortype(1);
122 TextRegion::_setcursortype(0);
125 bool is_cursor_enabled()
127 if (TextRegion::cursor_flag
)
135 return TextRegion::wherex();
140 return TextRegion::wherey();
143 int get_number_of_lines()
145 return tiles
.get_number_of_lines();
148 int get_number_of_cols()
150 return tiles
.get_number_of_cols();
153 void put_colour_ch(int colour
, unsigned ch
)
159 int window(int x1
, int y1
, int x2
, int y2
)
166 return (tiles
.getch_ck());
180 void cgotoxy(int x
, int y
, GotoRegion region
)
182 tiles
.cgotoxy(x
, y
, region
);
185 coord_def
cgetpos(GotoRegion region
)
187 ASSERT(region
== get_cursor_region());
188 return (coord_def(wherex(), wherey()));
191 GotoRegion
get_cursor_region()
193 return (tiles
.get_cursor_region());
204 tiles
.set_need_redraw();
209 // Look for the presence of any keyboard events in the queue.
210 int count
= wm
->get_event_count(WM_KEYDOWN
);
215 int itoa(int value
, char *strptr
, int radix
)
217 unsigned int bitmask
= 32768;
223 sprintf(strptr
, "%i", value
);
225 else if (radix
== 2) /* int to "binary string" */
232 sprintf(strptr
+ ctr
, "1");
236 sprintf(strptr
+ ctr
, "0");
239 bitmask
= bitmask
>> 1;
244 if (!startflag
) /* Special case if value == 0 */
245 sprintf((strptr
+ ctr
++), "0");
247 strptr
[ctr
] = (char) NULL
;
249 return (0); /* Me? Fail? Nah. */
253 // Convert string to lowercase.
254 char *strlwr(char *str
)
258 for (i
= 0; i
< strlen(str
); i
++)
259 str
[i
] = tolower(str
[i
]);
264 #endif // #ifdef UNIX
265 #endif // #ifdef USE_TILE