OSDN Git Service

First commitment for the BlackTank LPC1769.
[blacktank/blacktank.git] / text_editor.h
1 /**
2  * @file text_editor.h
3  * @author Shinichiro Nakamura
4  * @brief NT-Shell用テキストエディタモジュールの定義。
5  * @details
6  * 文字列の編集を論理的に扱うためのモジュール。
7  * このモジュールはビューに関して一切感知しない。
8  */
9
10 /*
11  * ===============================================================
12  *  Natural Tiny Shell (NT-Shell)
13  *  Version 0.0.7
14  * ===============================================================
15  * Copyright (c) 2010-2011 Shinichiro Nakamura
16  *
17  * Permission is hereby granted, free of charge, to any person
18  * obtaining a copy of this software and associated documentation
19  * files (the "Software"), to deal in the Software without
20  * restriction, including without limitation the rights to use,
21  * copy, modify, merge, publish, distribute, sublicense, and/or
22  * sell copies of the Software, and to permit persons to whom the
23  * Software is furnished to do so, subject to the following
24  * conditions:
25  *
26  * The above copyright notice and this permission notice shall be
27  * included in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
31  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
34  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
36  * OTHER DEALINGS IN THE SOFTWARE.
37  * ===============================================================
38  */
39
40 #ifndef _TEXT_EDITOR_H_
41 #define _TEXT_EDITOR_H_
42
43 #define TEXTEDITOR_MAXLEN 64
44
45 typedef struct {
46     char buffer[TEXTEDITOR_MAXLEN];
47     int pos;
48     int len;
49 } text_editor_t;
50
51 void text_editor_init(text_editor_t *p);
52 int text_editor_insert(text_editor_t *p, char c);
53 int text_editor_backspace(text_editor_t *p);
54 int text_editor_cursor_get_position(text_editor_t *p);
55 int text_editor_cursor_head(text_editor_t *p);
56 int text_editor_cursor_tail(text_editor_t *p);
57 int text_editor_cursor_left(text_editor_t *p);
58 int text_editor_cursor_right(text_editor_t *p);
59 int text_editor_set_text(text_editor_t *p, char *buf);
60 int text_editor_get_text(text_editor_t *p, char *buf, int siz);
61 void text_editor_clear(text_editor_t *p);
62
63 #endif
64