OSDN Git Service

Added NT modules.
[bluetank/bluetank.git] / firm / bare_metal / common / ntshell / text_history.h
1 /**
2  * @file text_history.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.8
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_HISTORY_H
41 #define TEXT_HISTORY_H
42
43 #include "ntconf.h"
44
45 /**
46  * @brief 1履歴あたりの文字列最大長。
47  */
48 #define TEXTHISTORY_MAXLEN  (NTCONF_EDITOR_MAXLEN)
49
50 /**
51  * @brief 履歴管理数。
52  */
53 #define TEXTHISTORY_DEPTH   (NTCONF_HISTORY_DEPTH)
54
55 /**
56  * @brief テキストヒストリ構造体。
57  */
58 typedef struct {
59     /**
60      * @brief 履歴文字列バッファ。
61      */
62     char history[TEXTHISTORY_MAXLEN * TEXTHISTORY_DEPTH];
63
64     /**
65      * @brief リード位置。
66      */
67     int rp;
68
69     /**
70      * @brief ライト位置。
71      */
72     int wp;
73 } text_history_t;
74
75 void text_history_init(text_history_t *p);
76 int text_history_write(text_history_t *p, char *buf);
77 int text_history_read(text_history_t *p, char *buf, const int siz);
78 int text_history_read_point_next(text_history_t *p);
79 int text_history_read_point_prev(text_history_t *p);
80 int text_history_find(text_history_t *p,
81         const int index, const char *text,
82         char *buf, const int siz);
83
84 #endif
85