OSDN Git Service

チケット #30493 , チケット #30494 , チケット #30502
[uzume/uzume_bfin.git] / uzumeapp / kernel / uzume / 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  * ===============================================================
14  * Copyright (c) 2010-2012 Shinichiro Nakamura
15  *
16  * Permission is hereby granted, free of charge, to any person
17  * obtaining a copy of this software and associated documentation
18  * files (the "Software"), to deal in the Software without
19  * restriction, including without limitation the rights to use,
20  * copy, modify, merge, publish, distribute, sublicense, and/or
21  * sell copies of the Software, and to permit persons to whom the
22  * Software is furnished to do so, subject to the following
23  * conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  * OTHER DEALINGS IN THE SOFTWARE.
36  * ===============================================================
37  */
38
39 #ifndef TEXT_HISTORY_H
40 #define TEXT_HISTORY_H
41
42 #include "ntconf.h"
43
44 /**
45  * @brief 1履歴あたりの文字列最大長。
46  */
47 #define TEXTHISTORY_MAXLEN  (NTCONF_EDITOR_MAXLEN)
48
49 /**
50  * @brief 履歴管理数。
51  */
52 #define TEXTHISTORY_DEPTH   (NTCONF_HISTORY_DEPTH)
53
54 /**
55  * @brief テキストヒストリ構造体。
56  */
57 typedef struct {
58     /**
59      * @brief 履歴文字列バッファ。
60      */
61     char history[TEXTHISTORY_MAXLEN * TEXTHISTORY_DEPTH];
62
63     /**
64      * @brief リード位置。
65      */
66     int rp;
67
68     /**
69      * @brief ライト位置。
70      */
71     int wp;
72 } text_history_t;
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 void text_history_init(text_history_t *p);
79 int text_history_write(text_history_t *p, char *buf);
80 int text_history_read(text_history_t *p, char *buf, const int siz);
81 int text_history_read_point_next(text_history_t *p);
82 int text_history_read_point_prev(text_history_t *p);
83 int text_history_find(text_history_t *p, const int index, const char *text, char *buf, const int siz);
84
85 #ifdef __cplusplus
86 }
87 #endif
88
89 #endif
90