File: libconsole.h

package info (click to toggle)
crawl 2%3A0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,188 kB
  • sloc: cpp: 363,709; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (75 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once

#include "defines.h"

void console_startup();
void console_shutdown();

class crawl_view_buffer;

int get_number_of_lines();
int get_number_of_cols();
int num_to_lines(int num);

void clrscr();
void clrscr_sys();
void clear_to_end_of_line();
void gotoxy_sys(int x, int y);
void textcolour(int c);
void textbackground(int c);
COLOURS default_hover_colour();
struct lib_display_info
{
    lib_display_info();
    string type;
    string term;
    int fg_colors;
    int bg_colors;
};
void cprintf(const char *format, ...);

int wherex();
int wherey();
void putwch(char32_t c);
int getch_ck();
bool kbhit();
void delay(unsigned int ms);
void puttext(int x, int y, const crawl_view_buffer &vbuf);
void update_screen();

void set_cursor_enabled(bool enabled);
bool is_cursor_enabled();
void set_mouse_enabled(bool enabled);

static inline void put_colour_ch(int colour, char32_t ch)
{
    textcolour(colour);
    putwch(ch);
}

struct coord_def;
coord_def cgetpos(GotoRegion region = GOTO_CRT);
void cgotoxy(int x, int y, GotoRegion region = GOTO_CRT);
GotoRegion get_cursor_region();
void set_cursor_region(GotoRegion region);

bool valid_cursor_pos(int x, int y, GotoRegion region);
void assert_valid_cursor_pos();

struct save_cursor_pos
{
    save_cursor_pos()
        : region(get_cursor_region()), pos(cgetpos(region))
    {
        ASSERTM(valid_cursor_pos(pos.x, pos.y, region),
            "invalid cursor position %d,%d in region %d", pos.x, pos.y, region);
    };
    ~save_cursor_pos()
    {
        cgotoxy(pos.x, pos.y, region);
    };

private:
    GotoRegion region;
    coord_def pos;
};