# textbuf_type.h

Go to the documentation of this file.

    00001 /* $Id: textbuf_type.h 25102 2013-03-17 20:58:40Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef TEXTBUF_TYPE_H
    00013 #define TEXTBUF_TYPE_H
    00014
    00015 #include "string_type.h"
    00016 #include "strings_type.h"
    00017
    00019 struct Textbuf {
    00020   CharSetFilter afilter;
    00021   char * const buf;
    00022   uint16 max_bytes;
    00023   uint16 max_chars;
    00024   uint16 bytes;
    00025   uint16 chars;
    00026   uint16 pixels;
    00027   bool caret;
    00028   uint16 caretpos;
    00029   uint16 caretxoffs;
    00030
    00031   explicit Textbuf(uint16 max_bytes, uint16 max_chars = UINT16_MAX);
    00032   ~Textbuf();
    00033
    00034   void Assign(StringID string);
    00035   void Assign(const char *text);
    00036   void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
    00037
    00038   void DeleteAll();
    00039   bool DeleteChar(int delmode);
    00040   bool InsertChar(uint32 key);
    00041   bool InsertClipboard();
    00042   bool MovePos(int navmode);
    00043
    00044   bool HandleCaret();
    00045   void UpdateSize();
    00046
    00047 private:
    00048   bool CanDelChar(bool backspace);
    00049   WChar GetNextDelChar(bool backspace);
    00050   void DelChar(bool backspace);
    00051   bool CanMoveCaretLeft();
    00052   WChar MoveCaretLeft();
    00053   bool CanMoveCaretRight();
    00054   WChar MoveCaretRight();
    00055
    00056 };
    00057
    00058 #endif /* TEXTBUF_TYPE_H */