OSDN Git Service

* Implement: (API) LibEditText_GetCursor(Range/RangeNext/Start/End/Line)String()...
authorKoine Yuusuke(koinec) <koinec@users.sourceforge.jp>
Tue, 30 Jun 2015 12:50:31 +0000 (21:50 +0900)
committerKoine Yuusuke(koinec) <koinec@users.sourceforge.jp>
Tue, 30 Jun 2015 12:50:31 +0000 (21:50 +0900)
include/libedittext.h
libedittext/drd64_libedittext_cursorapi_info.c
libedittext/drd64_libedittext_types.h

index f9f984e..cf034b5 100644 (file)
@@ -97,9 +97,15 @@ LIBEDITTEXT_API_LINEAPI
 #endif
 
 LIBEDITTEXT_API_CURSORAPI_INFO
-       const char *LibEditText_GetCursorLineString( int i_tinfoid, int i_curid );
+       const char *LibEditText_GetCursorRangeNextString( int i_tinfoid, int i_curid, DWord *pdw_len );
 LIBEDITTEXT_API_CURSORAPI_INFO
-       DWord LibEditText_GetCursorLineLength( int i_tinfoid, int i_curid );
+       const char * LibEditText_GetCursorRangeString( int i_tinfoid, int i_curid, DWord *pdw_len );
+LIBEDITTEXT_API_CURSORAPI_INFO
+       const char *LibEditText_GetCursorEndString( int i_tinfoid, int i_curid, DWord *pdw_len );
+LIBEDITTEXT_API_CURSORAPI_INFO
+       const char *LibEditText_GetCursorStartString( int i_tinfoid, int i_curid, DWord *pdw_len );
+LIBEDITTEXT_API_CURSORAPI_INFO
+       const char *LibEditText_GetCursorLineString( int i_tinfoid, int i_curid, DWord *pdw_len  );
 LIBEDITTEXT_API_CURSORAPI_INFO
        int LibEditText_AllocCursor( int i_tinfid, DWord dw_ranges );
 LIBEDITTEXT_API_CURSORAPI_INFO
index 3889f90..634b3f7 100644 (file)
@@ -42,14 +42,6 @@ Comment:
                                                DRD64_SRC_LIBEDITTEXT_CURSORAPI_INFO_SRCID, (n))
 
 /***********************************************************************
-  * GetCursorLineString
-  * GetCursorLineLength
-  * AllocCursor
-  * FreeCursor
-***********************************************************************/
-
-
-/***********************************************************************
 ***********************************************************************/
 /*
 LIBEDITTEXT_API_CURSORAPI_INFO
@@ -79,14 +71,28 @@ int
 
        
 /***********************************************************************
+  * GetCursorRangeString
+  * GetCursorRangeNextString
+  * GetCursorStartString
+  * GetCursorEndString
+  * GetCursorLineString
+  * GetCursorLineLength
+  * AllocCursor
+  * FreeCursor
+***********************************************************************/
+
+
+/***********************************************************************
+Implemented
 ***********************************************************************/
 LIBEDITTEXT_API_CURSORAPI_INFO
 const char *
-       LibEditText_GetCursorLineString(
+       LibEditText_GetCursorRangeNextString(
                        int             i_tinfoid,
-                       int             i_curid )
+                       int             i_curid,
+                       DWord   *pdw_len )
 {
-       Byte                                    *pb_str;
+       Byte                                    *pb_data;
        LibEditText_TextInfo    *p_tinfo;
        LibEditText_Cursor              *p_cursor;
        LibEditText_LineInfo    *p_line;
@@ -101,41 +107,170 @@ const char *
                return NULL;
        }
 
-       p_line  = LINFO(p_tinfo, p_cursor->dw_lineid);
+       if( p_cursor->dw_now_rngline == p_cursor->dw_rangelines )       { return NULL; }
+
+       p_line  = LINFO(p_tinfo, p_cursor->dw_now_linfoid);
+       if( NULL == p_line )    {
+               return NULL;
+       }
+
+       if( NULL != pdw_len )   { *pdw_len      = p_line->dw_strlen; }
+       pb_data = p_tinfo->pb_text + p_line->dw_start;
+       
+       p_cursor->dw_now_linfoid        = p_line->dw_next;
+       p_cursor->dw_now_rngline++;
+
+       return (const char *)pb_data;
+}
+
+       
+/***********************************************************************
+Implemented
+***********************************************************************/
+LIBEDITTEXT_API_CURSORAPI_INFO
+const char *
+       LibEditText_GetCursorRangeString(
+                       int             i_tinfoid,
+                       int             i_curid,
+                       DWord   *pdw_len )
+{
+       Byte                                    *pb_data;
+       LibEditText_TextInfo    *p_tinfo;
+       LibEditText_Cursor              *p_cursor;
+       LibEditText_LineInfo    *p_line;
+
+       p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+       if( NULL == p_tinfo )   {
+               return NULL;
+       }
+
+       p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
+       if( NULL == p_cursor )  {
+               return NULL;
+       }
+
+       if( 0 == p_cursor->dw_rangelines )      { return NULL; }
+
+       p_line  = LINFO(p_tinfo, p_cursor->dw_start_lineid);
        assert( NULL != p_line );
 
-       pb_str  = p_tinfo->pb_text + p_line->dw_start;
+       if( NULL != pdw_len )   { *pdw_len      = p_line->dw_strlen; }
+       pb_data = p_tinfo->pb_text + p_line->dw_start;
+       
+       p_cursor->dw_now_linfoid        = p_line->dw_next;
+       p_cursor->dw_now_rngline        = 1;
 
-       return  (const char *)pb_str;
+       return  (const char *)pb_data;
 }
 
        
 /***********************************************************************
+Implemented
 ***********************************************************************/
 LIBEDITTEXT_API_CURSORAPI_INFO
-DWord
-       LibEditText_GetCursorLineLength(
+const char *
+       LibEditText_GetCursorEndString(
                        int             i_tinfoid,
-                       int             i_curid )
+                       int             i_curid,
+                       DWord   *pdw_len )
+{
+       Byte                                    *pb_data;
+       LibEditText_TextInfo    *p_tinfo;
+       LibEditText_Cursor              *p_cursor;
+       LibEditText_LineInfo    *p_line;
+
+       p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+       if( NULL == p_tinfo )   {
+               return NULL;
+       }
+
+       p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
+       if( NULL == p_cursor )  {
+               return NULL;
+       }
+
+       if( 0 == p_cursor->dw_rangelines )      { return NULL; }
+
+       p_line  = LINFO(p_tinfo, p_cursor->dw_end_lineid);
+       
+       if( NULL != pdw_len )   { *pdw_len      = p_line->dw_strlen; }
+
+       pb_data = p_tinfo->pb_text + p_line->dw_start;
+
+       return  (const char *)pb_data;
+}
+
+       
+/***********************************************************************
+Implemented
+***********************************************************************/
+LIBEDITTEXT_API_CURSORAPI_INFO
+const char *
+       LibEditText_GetCursorStartString(
+                       int             i_tinfoid,
+                       int             i_curid,
+                       DWord   *pdw_len )
 {
+       Byte                                    *pb_data;
        LibEditText_TextInfo    *p_tinfo;
        LibEditText_Cursor              *p_cursor;
        LibEditText_LineInfo    *p_line;
 
        p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
        if( NULL == p_tinfo )   {
-               return MAXLINES;
+               return NULL;
        }
 
        p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
        if( NULL == p_cursor )  {
-               return MAXLINES;
+               return NULL;
+       }
+
+       if( 0 == p_cursor->dw_rangelines )      { return NULL; }
+
+       p_line  = LINFO(p_tinfo, p_cursor->dw_start_lineid);
+       
+       if( NULL != pdw_len )   { *pdw_len      = p_line->dw_strlen; }
+
+       pb_data = p_tinfo->pb_text + p_line->dw_start;
+
+       return  (const char *)pb_data;
+}
+
+       
+/***********************************************************************
+Implemented
+***********************************************************************/
+LIBEDITTEXT_API_CURSORAPI_INFO
+const char *
+       LibEditText_GetCursorLineString(
+                       int             i_tinfoid,
+                       int             i_curid,
+                       DWord   *pdw_len  )
+{
+       Byte                                    *pb_str;
+       LibEditText_TextInfo    *p_tinfo;
+       LibEditText_Cursor              *p_cursor;
+       LibEditText_LineInfo    *p_line;
+
+       p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+       if( NULL == p_tinfo )   {
+               return NULL;
+       }
+
+       p_cursor        = LibEditText_CursorInfo_GetCursor( p_tinfo, i_curid );
+       if( NULL == p_cursor )  {
+               return NULL;
        }
 
        p_line  = LINFO(p_tinfo, p_cursor->dw_lineid);
        assert( NULL != p_line );
 
-       return p_line->dw_strlen;
+       if( NULL != pdw_len )   { *pdw_len      = p_line->dw_strlen; }
+
+       pb_str  = p_tinfo->pb_text + p_line->dw_start;
+
+       return  (const char *)pb_str;
 }
 
        
index 8420f92..74f4ac3 100644 (file)
@@ -81,6 +81,8 @@ typedef struct        {
        DWord   dw_end_line;
         
        DWord   dw_rangelines;
+       DWord   dw_now_linfoid;
+       DWord   dw_now_rngline;
 
        Byte    b_update;
 } LibEditText_Cursor;