#define LibEditText_DownCursor(m,n) LibEditText_MoveDownCursor((m),(n),1)
LIBEDITTEXT_API_CURSORAPI_MOVE
+ int LibEditText_SetCursor( int i_tinfoid, int i_curid, DWord dw_pos );
+LIBEDITTEXT_API_CURSORAPI_MOVE
int LibEditText_MoveEndCursor( int i_tinfoid, int i_curid );
LIBEDITTEXT_API_CURSORAPI_MOVE
int LibEditText_MoveStartCursor( int i_tinfoid, int i_curid );
}
if( '\n' == c_char ) {
+ i_result = LibEditText_LineCtrl_SplitLine(
+ p_tinfo, p_cursor->dw_lineid, p_cursor->dw_line, p_cursor->dw_pos );
+ if( 0x00 != i_result ) {
+ return -0x03;
+ }
+/*
dw_line = LibEditText_LineCtrl_AddLine(
p_tinfo, p_cursor->dw_lineid, p_cursor->dw_line, 0, 0x00 );
if( INVALID_LINE == dw_line ) {
return -0x03;
}
-
+*/
i_result = LibEditText_CursorMove_MoveDown( p_tinfo, p_cursor, 1 );
}
else {
***********************************************************************/
LIBEDITTEXT_API_CURSORAPI_MOVE
int
+ LibEditText_SetCursor(
+ int i_tinfoid,
+ int i_curid,
+ DWord dw_pos )
+{
+ int i_result;
+ LibEditText_TextInfo *p_tinfo;
+ LibEditText_Cursor *p_cursor;
+
+ p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+ if( NULL == p_tinfo ) {
+ return -0x01;
+ }
+
+ p_cursor = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
+ if( NULL == p_cursor ) {
+ return -0x02;
+ }
+
+ i_result = LibEditText_CursorMove_SetPosition( p_tinfo, p_cursor, dw_pos );
+ return i_result;
+}
+
+
+/***********************************************************************
+Implemented
+***********************************************************************/
+LIBEDITTEXT_API_CURSORAPI_MOVE
+int
LibEditText_MoveEndCursor(
int i_tinfoid,
int i_curid )
----------------------------------------------------------------------*/
LIBEDITTEXT_CURSORMOVE_EXTERN
int
+ LibEditText_CursorMove_SetPosition(
+ LibEditText_TextInfo *p_tinfo,
+ LibEditText_Cursor *p_cursor,
+ DWord dw_pos )
+{
+ LibEditText_LineInfo *p_line;
+
+ assert( NULL != p_tinfo );
+ assert( NULL != p_cursor );
+
+ p_line = LINFO(p_tinfo, p_cursor->dw_lineid);
+ assert( NULL != p_line );
+
+ if( p_cursor->dw_line + 1 == p_tinfo->dw_maxline ) {
+ if( dw_pos > p_line->dw_strlen ) {
+ return 0x01;
+ }
+ }
+ else {
+ if( dw_pos >= p_line->dw_strlen ) {
+ return 0x01;
+ }
+ }
+
+ p_cursor->dw_pos = dw_pos;
+
+ return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBEDITTEXT_CURSORMOVE_EXTERN
+int
LibEditText_CursorMove_MoveEnd(
LibEditText_TextInfo *p_tinfo,
LibEditText_Cursor *p_cursor )
#endif
LIBEDITTEXT_CURSORMOVE_EXTERN
+ int LibEditText_CursorMove_SetPosition(
+ LibEditText_TextInfo *p_tinfo, LibEditText_Cursor *p_cursor, DWord dw_pos );
+LIBEDITTEXT_CURSORMOVE_EXTERN
int LibEditText_CursorMove_MoveEnd(
LibEditText_TextInfo *p_tinfo, LibEditText_Cursor *p_cursor );
LIBEDITTEXT_CURSORMOVE_EXTERN
p_line = LINFO(p_tinfo, dw_lineid);
assert( NULL != p_line );
- assert( p_line->dw_strlen > dw_pos );
+ assert( p_line->dw_strlen >= dw_pos );
dw_nextlength = p_line->dw_strlen - dw_pos;
pb_str = p_tinfo->pb_text + p_line->dw_start + dw_pos;
return -0x12;
}
+ p_line = LINFO(p_tinfo, dw_lineid);
+ assert( NULL != p_line );
+ pb_str = p_tinfo->pb_text + p_line->dw_start + dw_pos;
+
memset( pb_str, 0x00, dw_nextlength );
*pb_str = '\n';
p_line->dw_strlen = dw_pos + 1;
CU_ASSERT( dw_nowline == 0 );
- /* TestPhase C --- Delete Data ==============================*/
+ /* TestPhase D --- SplitLine & OutputData ===================*/
+ do {
+ pstr_data = LibEditText_GetCursorLineString( i_tinfoid, i_curid, &dw_len );
+ CU_ASSERT( NULL != pstr_data );
+
+ if( 0 < dw_len ) {
+ dw_pos = rand() % dw_len;
+ }
+ else {
+ dw_pos = 0;
+ }
+ i_result = LibEditText_SetCursor( i_tinfoid, i_curid, dw_pos );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_InsertChar( i_tinfoid, i_curid, '\n' );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_MoveDownCursor( i_tinfoid, i_curid, 1);
+ }while( 0x00 == i_result );
+
+ i_result = LibEditText_GetCursorPosition( i_tinfoid, i_curid, &dw_nowline, &dw_pos );
+ CU_ASSERT( 0x00 == i_result );
+
+ dw_maxline = LibEditText_GetMaxLines( i_tinfoid );
+ CU_ASSERT( dw_nowline + 1 == dw_maxline );
+
+ /* TestPhase E --- Delete Data ==============================*/
/* Test 30 --- JoinLine */
+ i_result = LibEditText_JumpCursor( i_tinfoid, i_curb, 0 );
+ CU_ASSERT( 0x00 == i_result );
+
+ do {
+ i_result = LibEditText_JoinLine( i_tinfoid, i_curb );
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibEditText_MoveDownCursor( i_tinfoid, i_curb, 1);
+ }while( 0x00 == i_result );
+
+ i_result = LibEditText_GetCursorPosition( i_tinfoid, i_curb, &dw_nowline, &dw_pos );
+ CU_ASSERT( 0x00 == i_result );
+
+ dw_maxline = LibEditText_GetMaxLines( i_tinfoid );
+ CU_ASSERT( dw_nowline + 1 == dw_maxline );
+
+ //i_result = LibEditText_GetCursorPosition( i_tinfoid, i_curid, &dw_nowline, &dw_pos );
/* Test 31 --- BackSpace */
/* Test 34 --- DeleteLine */
+ /* TestPhase F --- Delete Data ==============================*/
i_result = LibEditText_FreeCursor( i_tinfoid, i_curb );
CU_ASSERT( 0x00 == i_result );