OSDN Git Service

* Implement: API MoveCursor(Right/Left/Up/Down) (non-tested)
[drdeamon64/drdeamon64.git] / libedittext / drd64_libedittext_cursorapi.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11  1. Redistributions of source code must retain the above copyright notice,
12     this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #define DRD64_SRC_LIBEDITTEXT_CURSORAPI
38 #include"drd64_libedittext.h"
39
40 #define LOCATION(n)     DRD64_ERR_LOCATION( \
41                                                 DRD64_ERROR_MODULE_LIBEDITTEXT, DRD64_ERROR_ARCH_NODEPEND, \
42                                                 DRD64_SRC_LIBEDITTEXT_CURSORAPI_SRCID, (n))
43
44 /***********************************************************************
45   InsertString
46   InsertChar
47   BackSpace
48   DeleteString
49   DeleteChar
50   JoinLine
51   EndCursor(End)
52   StartCursor(Start)
53   * MoveCursor(Right)
54   * MoveCursor(Left)
55   * MoveCursor(Up)
56   * MoveCursor(Down)
57   * JumpCursor
58   * AllocCursor
59   * FreeCursor
60 ***********************************************************************/
61
62
63 /***********************************************************************
64 ***********************************************************************/
65 /*LIBEDITTEXT_API_CURSORAPI
66 int
67         LibEditText_MoveEndCursor(
68                         int             i_tinfoid,
69                         int             i_curid )
70 {
71         int             i_result;
72         LibEditText_TextInfo    *p_tinfo;
73         LibEditText_Cursor              *p_cursor;
74         LibEditText_LineInfo    *p_line;
75
76         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
77         if( NULL == p_tinfo )   {
78                 return -0x01;
79         }
80
81         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
82         if( NULL == p_cursor )  {
83                 return -0x02;
84         }
85
86         p_line          = LINFO(p_tinfo, p_cursor->dw_lineid);
87         if( NULL == p_line )    {
88                 return -0x03;
89         }
90
91         i_result        = LibEditText_CursorMove_MoveRight( p_tinfo, p_cursor, dw_len );
92         return  i_result;
93 }*/
94
95
96 /***********************************************************************
97 ***********************************************************************/
98 LIBEDITTEXT_API_CURSORAPI
99 int
100         LibEditText_MoveUpCursor(
101                         int             i_tinfoid,
102                         int             i_curid,
103                         DWord   dw_lines )
104 {
105         int             i_result;
106         LibEditText_TextInfo    *p_tinfo;
107         LibEditText_Cursor              *p_cursor;
108
109         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
110         if( NULL == p_tinfo )   {
111                 return -0x01;
112         }
113
114         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
115         if( NULL == p_cursor )  {
116                 return -0x02;
117         }
118
119         i_result        = LibEditText_CursorMove_MoveUp( p_tinfo, p_cursor, dw_lines );
120         return  i_result;
121 }
122
123
124 /***********************************************************************
125 ***********************************************************************/
126 LIBEDITTEXT_API_CURSORAPI
127 int
128         LibEditText_MoveDownCursor(
129                         int             i_tinfoid,
130                         int             i_curid,
131                         DWord   dw_lines )
132 {
133         int             i_result;
134         LibEditText_TextInfo    *p_tinfo;
135         LibEditText_Cursor              *p_cursor;
136
137         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
138         if( NULL == p_tinfo )   {
139                 return -0x01;
140         }
141
142         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
143         if( NULL == p_cursor )  {
144                 return -0x02;
145         }
146
147         i_result        = LibEditText_CursorMove_MoveDown( p_tinfo, p_cursor, dw_lines );
148         return  i_result;
149 }
150
151
152 /***********************************************************************
153 ***********************************************************************/
154 LIBEDITTEXT_API_CURSORAPI
155 int
156         LibEditText_MoveRightCursor(
157                         int             i_tinfoid,
158                         int             i_curid,
159                         DWord   dw_len )
160 {
161         int             i_result;
162         LibEditText_TextInfo    *p_tinfo;
163         LibEditText_Cursor              *p_cursor;
164
165         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
166         if( NULL == p_tinfo )   {
167                 return -0x01;
168         }
169
170         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
171         if( NULL == p_cursor )  {
172                 return -0x02;
173         }
174
175         i_result        = LibEditText_CursorMove_MoveRight( p_tinfo, p_cursor, dw_len );
176         return  i_result;
177 }
178
179
180 /***********************************************************************
181 ***********************************************************************/
182 LIBEDITTEXT_API_CURSORAPI
183 int
184         LibEditText_MoveLeftCursor(
185                         int             i_tinfoid,
186                         int             i_curid,
187                         DWord   dw_len )
188 {
189         int             i_result;
190         LibEditText_TextInfo    *p_tinfo;
191         LibEditText_Cursor              *p_cursor;
192
193         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
194         if( NULL == p_tinfo )   {
195                 return -0x01;
196         }
197
198         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
199         if( NULL == p_cursor )  {
200                 return -0x02;
201         }
202
203         i_result        = LibEditText_CursorMove_MoveLeft( p_tinfo, p_cursor, dw_len );
204         return  i_result;
205 }
206
207
208 /***********************************************************************
209 ***********************************************************************/
210 LIBEDITTEXT_API_CURSORAPI
211 int
212         LibEditText_JumpCursor(
213                         int             i_tinfoid, 
214                         int             i_curid,
215                         DWord   dw_line )
216 {
217         int             i_result;
218         LibEditText_TextInfo    *p_tinfo;
219         LibEditText_Cursor              *p_cursor;
220
221         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
222         if( NULL == p_tinfo )   {
223                 return -0x01;
224         }
225
226         p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
227         if( NULL == p_cursor )  {
228                 return -0x02;
229         }
230
231         i_result        = LibEditText_CursorInfo_JumpCursor( p_tinfo, p_cursor, dw_line );
232
233         return i_result;
234 }
235
236
237 /***********************************************************************
238 ***********************************************************************/
239 LIBEDITTEXT_API_CURSORAPI
240 int
241         LibEditText_AllocCursor(
242                         int     i_tinfoid,
243                         DWord dw_ranges )
244 {
245         int             i_curid;
246         LibEditText_TextInfo    *p_tinfo;
247
248         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
249         if( NULL == p_tinfo )   {
250                 return -0x01;
251         }
252
253         i_curid = LibEditText_CursorInfo_AllocCursor( p_tinfo, dw_ranges );
254         
255         return i_curid;
256 }
257
258
259 /***********************************************************************
260 ***********************************************************************/
261 LIBEDITTEXT_API_CURSORAPI
262 int
263         LibEditText_FreeCursor(
264                         int     i_tinfoid,
265                         int     i_curid )
266 {
267         int             i_result;
268         LibEditText_TextInfo    *p_tinfo;
269
270         p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
271         if( NULL == p_tinfo )   {
272                 return -0x01;
273         }
274
275         i_result        = LibEditText_CursorInfo_FreeCursor( p_tinfo, i_curid );
276
277         return i_result;
278 }
279
280
281
282 /* EOF of drd64_.c ----------------------------------- */