# textbuf_type.h

Go to the documentation of this file.

    00001 /* $Id$ */
    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
    00018 struct Textbuf {
    00019   char *buf;
    00020   uint16 max_bytes;
    00021   uint16 max_chars;
    00022   uint16 bytes;
    00023   uint16 chars;
    00024   uint16 pixels;
    00025   bool caret;
    00026   uint16 caretpos;
    00027   uint16 caretxoffs;
    00028
    00029   void Initialize(char *buf, uint16 max_bytes);
    00030   void Initialize(char *buf, uint16 max_bytes, uint16 max_chars);
    00031
    00032   void DeleteAll();
    00033   bool DeleteChar(int delmode);
    00034   bool InsertChar(uint32 key);
    00035   bool InsertClipboard();
    00036   bool MovePos(int navmode);
    00037
    00038   bool HandleCaret();
    00039   void UpdateSize();
    00040
    00041 private:
    00042   bool CanDelChar(bool backspace);
    00043   WChar GetNextDelChar(bool backspace);
    00044   void DelChar(bool backspace);
    00045   bool CanMoveCaretLeft();
    00046   WChar MoveCaretLeft();
    00047   bool CanMoveCaretRight();
    00048   WChar MoveCaretRight();
    00049
    00050 };
    00051
    00052 #endif /* TEXTBUF_TYPE_H */