engine: reject mbf21 and shit24 wads. there is no way to know if it is safe to ignore...
[k8vavoom.git] / source / iline.h
blobfaf0b227432c6c72d6d6152587f2b1a7bdf243a1
1 //**************************************************************************
2 //**
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
9 //**
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
21 //**
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 //**
27 //** input line library
28 //**
29 //**************************************************************************
30 #ifndef CL_ILINE_HEADER
31 #define CL_ILINE_HEADER
34 // input text line widget
35 class TILine {
36 protected:
37 char *data; // line of text (zero-terminated)
38 int len; // current line length
39 int maxlen;
40 int curpos;
41 int vischars; // number of on-screen visible chars
42 int visfirst; // first visible char in current string
43 // temp buffer for renderer
44 char *temp;
45 int tempsize;
47 protected:
48 void setup ();
50 void ensureCursorVisible ();
52 public:
53 char cursorChar;
55 public:
56 TILine () : data(nullptr), len(0), maxlen(0), curpos(0), vischars(80), visfirst(0), temp(nullptr), tempsize(0), cursorChar('_') { setup(); }
57 TILine (int amaxlen) : data(nullptr), len(0), maxlen(amaxlen), curpos(0), vischars(80), visfirst(0), temp(nullptr), tempsize(0), cursorChar('_') { setup(); }
58 ~TILine ();
60 inline int length () const { return len; }
61 inline int maxLength () const { return maxlen; }
62 inline const char *getCStr () const { return data; }
63 inline const char *operator * () const { return data; }
65 inline int getCurPos () const { return clampval(curpos, 0, len); }
66 inline void setCurPos (int cpos) { curpos = cpos; ensureCursorVisible(); }
68 void SetVisChars (int vc);
70 void Init ();
71 void AddString (VStr s);
72 void AddString (const char *s);
73 void AddChar (char ch);
74 void DelChar (); // this does "backspace"
75 void RemoveChar (); // this removes char at the current cursor position, and doesn't move cursor
76 void DelWord ();
77 void WordLeft ();
78 void WordRight ();
79 bool Key (const event_t &ev); // whether eaten
81 // font and align should be already set
82 void DrawAt (int x0, int y0, int clrNormal=CR_ORANGE, int clrLR=CR_FIRE);
86 #endif