1 | /**
|
---|
2 | * @file text_history.h
|
---|
3 | * @author CuBeatSystems
|
---|
4 | * @author Shinichiro Nakamura
|
---|
5 | * @copyright
|
---|
6 | * ===============================================================
|
---|
7 | * Natural Tiny Shell (NT-Shell) Version 0.3.1
|
---|
8 | * ===============================================================
|
---|
9 | * Copyright (c) 2010-2016 Shinichiro Nakamura
|
---|
10 | *
|
---|
11 | * Permission is hereby granted, free of charge, to any person
|
---|
12 | * obtaining a copy of this software and associated documentation
|
---|
13 | * files (the "Software"), to deal in the Software without
|
---|
14 | * restriction, including without limitation the rights to use,
|
---|
15 | * copy, modify, merge, publish, distribute, sublicense, and/or
|
---|
16 | * sell copies of the Software, and to permit persons to whom the
|
---|
17 | * Software is furnished to do so, subject to the following
|
---|
18 | * conditions:
|
---|
19 | *
|
---|
20 | * The above copyright notice and this permission notice shall be
|
---|
21 | * included in all copies or substantial portions of the Software.
|
---|
22 | *
|
---|
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
25 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
27 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
28 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
30 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef TEXT_HISTORY_H
|
---|
34 | #define TEXT_HISTORY_H
|
---|
35 |
|
---|
36 | #include "ntconf.h"
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @brief Maximum length per a history.
|
---|
40 | */
|
---|
41 | #define TEXTHISTORY_MAXLEN (NTCONF_EDITOR_MAXLEN)
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @brief Depth of the history.
|
---|
45 | */
|
---|
46 | #define TEXTHISTORY_DEPTH (NTCONF_HISTORY_DEPTH)
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * @brief Structure of the text history module.
|
---|
50 | */
|
---|
51 | typedef struct {
|
---|
52 | /**
|
---|
53 | * @brief History buffer.
|
---|
54 | */
|
---|
55 | char history[TEXTHISTORY_MAXLEN * TEXTHISTORY_DEPTH];
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * @brief Read pointer.
|
---|
59 | */
|
---|
60 | int rp;
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * @brief Write pointer.
|
---|
64 | */
|
---|
65 | int wp;
|
---|
66 | } text_history_t;
|
---|
67 |
|
---|
68 | #ifdef __cplusplus
|
---|
69 | extern "C" {
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | void text_history_init(text_history_t *p);
|
---|
73 | int text_history_write(text_history_t *p, char *buf);
|
---|
74 | int text_history_read(text_history_t *p, char *buf, const int siz);
|
---|
75 | int text_history_read_point_next(text_history_t *p);
|
---|
76 | int text_history_read_point_prev(text_history_t *p);
|
---|
77 | int text_history_find(text_history_t *p, const int index, const char *text, char *buf, const int siz);
|
---|
78 |
|
---|
79 | #ifdef __cplusplus
|
---|
80 | }
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | #endif
|
---|
84 |
|
---|