#define LIBEDITTEXT_API_LINECTRL extern
#endif
LIBEDITTEXT_API_LINECTRL
+ int LibEditText_InsertLine_toLine( int i_tinfoid, DWord dw_line, char *pstr_text, DWord dw_length );
+LIBEDITTEXT_API_LINECTRL
int LibEditText_AppendLine( int i_tinfoid, char *pstr_text, DWord dw_length );
-
#ifdef DRD64_SRC_LIBEDITTEXT_LINEEDIT
#define LIBEDITTEXT_API_LINEEDIT
#else
#ifndef DRD64_HEADER_LIBEDITTEXT_CONFIG
#define DRD64_HEADER_LIBEDITTEXT_CONFIG
-#define DEBUG_TEXTINFO_OUTPUT 0x02
+#define DEBUG_TEXTINFO_OUTPUT 0x00
/* Output TextData for Console if this value isn't 0x00 when run test_drcc program.*/
#define DRD64_SRC_LIBEDITTEXT_LINECTRL
#include"drd64_libedittext.h"
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBEDITTEXT_LINECTRL_EXTERN
+int
+ LibEditText_LineCtrl_InsertLine(
+ LibEditText_TextInfo *p_tinfo,
+ LibEditText_LineInfo *p_lnext,
+ Byte *pb_text,
+ DWord dw_length )
+{
+ int i_result;
+ DWord dw_buflength;
+ DWord dw_strlen;
+ LibEditText_LineInfo *p_lbefore;
+ LibEditText_LineInfo *p_line;
+
+ assert( NULL != p_tinfo );
+ assert( NULL != p_lnext );
+
+ // PreProccess
+ p_lbefore = LINFO(p_tinfo, p_lnext->dw_before);
+
+ dw_strlen = dw_length;
+ if( '\n' != *(pb_text + dw_length) ) { dw_strlen++; }
+
+ // Get LineInfo struct
+ dw_buflength = dw_strlen + DRD64_LIBEDITTEXT_DEFAULT_RESERVEBUF_INLINE;
+ p_line = LibEditText_LineInfo_GetEmptyLineInfo( p_tinfo, dw_buflength );
+ if( NULL == p_line ) { return -0x11; }
+
+ // Link Before & After LineInfo
+ if( NULL != p_lbefore ) {
+ p_lbefore->dw_next = p_line->dw_id;
+ p_line->dw_before = p_lbefore->dw_id;
+ }
+ else
+ { p_tinfo->dw_line_start = p_line->dw_id; }
+
+ p_lnext->dw_before = p_line->dw_id;
+ p_line->dw_next = p_lnext->dw_id;
+
+ // Set LineInfo to SortChain
+ i_result = LibEditText_LineInfo_AddSortChain( p_tinfo, p_line );
+ if( 0x00 != i_result ) { return -0x12; }
+
+ // Set Init. TextData
+ p_line->dw_strlen = dw_strlen;
+ memcpy( p_tinfo->pb_text + p_line->dw_start, pb_text, dw_length );
+ if( dw_length != dw_strlen )
+ { *(p_tinfo->pb_text + p_line->dw_start + dw_length) = '\n'; }
+
+ p_tinfo->dw_maxline++;
+
+ // Adjust LineSection
+ i_result = LibEditText_Section_AddSection( p_tinfo );
+ if( 0x00 != i_result ) { return -0x13; }
+
+ return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBEDITTEXT_API_LINECTRL
+int
+ LibEditText_InsertLine_toLine(
+ int i_tinfoid,
+ DWord dw_line,
+ char *pstr_text,
+ DWord dw_length )
+{
+ int i_result;
+ LibEditText_TextInfo *p_tinfo;
+ LibEditText_LineInfo *p_line;
+
+ if( 0 > i_tinfoid ) { return -0x01; }
+ p_tinfo = LibEditText_System_GetTextInfo( i_tinfoid );
+ if( NULL == p_tinfo ) { return -0x02; }
+
+ if( NULL == pstr_text ) { return -0x03; }
+
+ if( p_tinfo->dw_maxline <= (dw_line + 1) ) {
+ i_result = LibEditText_LineCtrl_AppendLine(
+ p_tinfo, (Byte *)pstr_text, dw_length, 0x00 );
+ }
+ else {
+ p_line = LibEditText_Section_SearchLine( p_tinfo, dw_line );
+ i_result = LibEditText_LineCtrl_InsertLine(
+ p_tinfo, p_line, (Byte *)pstr_text, dw_length );
+ }
+
+ return i_result;
+}
+
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
memcpy( p_tinfo->pb_text + p_line->dw_start, pstr_text, dw_length );
+ p_tinfo->dw_line_end = p_line->dw_id;
+
/* Normal Append Mode is b_mode=0x00. */
if( 0x00 == b_mode ) {
- i_result = LibEditText_Section_AppendLine( p_tinfo, p_line );
p_tinfo->dw_maxline++;
+ i_result = LibEditText_Section_AddSection( p_tinfo );
}
- p_tinfo->dw_line_end = p_line->dw_id;
-
return 0x00;
}
#define LIBEDITTEXT_LINECTRL_INTERNALFUNC
#endif
-
+LIBEDITTEXT_LINECTRL_EXTERN
+ int LibEditText_LineCtrl_InsertLine(
+ LibEditText_TextInfo *p_tinfo, LibEditText_LineInfo *p_lnext,
+ Byte *pb_text, DWord dw_length );
LIBEDITTEXT_LINECTRL_EXTERN
int LibEditText_LineCtrl_AppendLine(
LibEditText_TextInfo *p_tinfo, Byte *pstr_text, DWord dw_length, Byte b_mode );
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
-LIBEDITTEXT_SECTION_EXTERN
-DWord inline
- LibEditText_Section_CalcSectionID(
- LibEditText_TextInfo *p_tinfo,
- DWord dw_line )
-{
- DWord dw_sectionid;
-
- assert( NULL != p_tinfo );
- dw_sectionid = (dw_line * p_tinfo->dw_sections) / p_tinfo->dw_maxline;
-
- return dw_sectionid;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
DWord
LibEditText_Section_BackwardSections_toNearTargetLine(
LibEditText_TextInfo *p_tinfo,
p_sec_min = SECINFO(p_tinfo, dw_secid_min);
p_sec_high = SECINFO(p_tinfo, dw_secid_high);
- for( dw_cnt = 0; dw_cnt < p_tinfo->dw_sections - 1; dw_cnt++ ) {
- if( dw_cnt < dw_secid_min ) {
+ if( 0 < dw_secid_min ) {
+ for( dw_cnt = dw_secid_min - 1; dw_cnt < dw_secid_min; dw_cnt--) {
p_sec_now = SECINFO(p_tinfo, dw_cnt);
if( p_sec_min->dw_line < p_sec_now->dw_line ) {
p_sec_now->dw_line = p_sec_min->dw_line;
p_sec_now->dw_linfoid = p_sec_min->dw_linfoid;
}
+ else { break; }
}
- else if( dw_cnt > dw_secid_high ) {
- p_sec_now = SECINFO(p_tinfo, dw_cnt);
+ }
- if( p_sec_high->dw_line > p_sec_now->dw_line ) {
- p_sec_now->dw_line = p_sec_high->dw_line;
- p_sec_now->dw_linfoid = p_sec_high->dw_linfoid;
- }
- else
- { return; }
- }
+ for( dw_cnt = dw_secid_high; dw_cnt < p_tinfo->dw_sections - 1; dw_cnt++ ) {
+ p_sec_now = SECINFO(p_tinfo, dw_cnt);
+ if( p_sec_high->dw_line > p_sec_now->dw_line ) {
+ p_sec_now->dw_line = p_sec_high->dw_line;
+ p_sec_now->dw_linfoid = p_sec_high->dw_linfoid;
+ }
+ else { return; }
}
return;
----------------------------------------------------------------------*/
LIBEDITTEXT_SECTION_EXTERN
int
- LibEditText_Section_AppendLine(
- LibEditText_TextInfo *p_tinfo,
- LibEditText_LineInfo *p_line )
+ LibEditText_Section_AddSection(
+ LibEditText_TextInfo *p_tinfo )
{
int i_result;
DWord dw_nowsec;
+ LibEditText_LineInfo *p_line;
LibEditText_LineSection *p_section;
- dw_nowsec = (p_tinfo->dw_maxline + 1) / p_tinfo->dw_sect_steps;
+ p_line = LINFO(p_tinfo, p_tinfo->dw_line_end );
+ assert( NULL != p_line );
+
+ dw_nowsec = p_tinfo->dw_maxline / p_tinfo->dw_sect_steps;
if( p_tinfo->dw_sections > dw_nowsec ) { return 0x00; }
if( p_tinfo->dw_bufsections == dw_nowsec ) {
i_result = LibEditText_Section_ExpandSectionInfo( p_tinfo );
if( 0x00 != i_result ) { return i_result; }
- dw_nowsec = (p_tinfo->dw_maxline + 1) / p_tinfo->dw_sect_steps;
+ dw_nowsec = p_tinfo->dw_maxline / p_tinfo->dw_sect_steps;
if( p_tinfo->dw_sections > dw_nowsec ) { return 0x00; }
}
p_section = p_tinfo->p_section + dw_nowsec;
assert( NULL != p_section );
- p_section->dw_line = p_tinfo->dw_maxline + 1;
+ p_section->dw_line = p_tinfo->dw_maxline;
p_section->dw_linfoid = p_line->dw_id;
p_tinfo->dw_sections++;
LIBEDITTEXT_SECTION_EXTERN
LibEditText_LineInfo *
- LibEditText_Section_SearchLine( LibEditText_TextInfo *p_tinfo, DWord dw_targline );
-LIBEDITTEXT_SECTION_EXTERN
- DWord inline LibEditText_CalcSectionID(
- LibEditText_TextInfo *p_tinfo, DWord dw_line );
+ LibEditText_Section_SearchLine(
+ LibEditText_TextInfo *p_tinfo, DWord dw_targline );
LIBEDITTEXT_SECTION_EXTERN
int LibEditText_Section_ConstractSection(
LibEditText_TextInfo *p_tinfo );
LIBEDITTEXT_SECTION_EXTERN
- int LibEditText_Section_AppendLine(
- LibEditText_TextInfo *p_tinfo, LibEditText_LineInfo *p_line );
+ int LibEditText_Section_AddSection(
+ LibEditText_TextInfo *p_tinfo );
LIBEDITTEXT_SECTION_EXTERN
int LibEditText_Section_TermSection(
LibEditText_TextInfo *p_tinfo );
LibEditText_TextInfo *p_tinfo, DWord dw_secid, DWord dw_targetline );
DWord LibEditText_Section_ForwardSections_toNearTargetLine(
LibEditText_TextInfo *p_tinfo, DWord dw_secid, DWord dw_targetline );
+void LibEditText_Section_ReviewSection(
+ LibEditText_TextInfo *p_tinfo, DWord dw_secid_min, DWord dw_secid_high );
DWord LibEditText_Section_SearchLine_OldSectionInfo(
LibEditText_LineSection *p_section, LibEditText_TextInfo *p_tinfo,
DWord dw_secid, DWord dw_line );