TODO: testing delete-line in the imtermidiate line of file.
assert( NULL != p_tinfo );
assert( NULL != p_line );
- if( 1 == p_tinfo->dw_maxline ) { return 0x00; }
+ if( 1 == p_tinfo->dw_maxline ) { return 0x00; }
// Check & Remove Section ---
LibEditText_Section_DeleteLine( p_tinfo, dw_line );
i_result = LibEditText_Section_AddSection( p_tinfo );
if( 0x00 > i_result ) { return i_result; }
else if( 0x00 < i_result ) { i_result = 0x00; }
+
p_tinfo->dw_maxline++;
}
/* Follow if-block is memory-garbage collect proc if this is in last buffer */
if( p_tinfo->dw_lastsize == p_line->dw_start + p_line->dw_linelen ) {
- p_line->dw_linelen = 0;
- p_line->dw_strlen = 0;
- p_line->dw_start = 0;
+ p_tinfo->dw_lastsize -= p_line->dw_linelen;
+ p_line->dw_linelen = 0;
+ p_line->dw_strlen = 0;
+ p_line->dw_start = 0;
}
i_element = LibEditText_LineInfo_CalcSortChainElement( p_line->dw_linelen );
int i_element;
LibEditText_LineInfo *p_sort;
LibEditText_LineInfo *p_before;
-
+ DWord dw_cnt=0;
assert( 0 != p_line->dw_linelen);
i_element = LibEditText_LineInfo_CalcSortChainElement( p_line->dw_linelen );
while(( NULL != p_sort ) && ( p_line != p_sort )) {
p_before = p_sort;
p_sort = LINFO(p_tinfo, p_before->dw_sortnext);
+ dw_cnt++;
}
if( NULL == p_sort ) { return -0x02; }
if( NULL != p_before)
{ p_before->dw_sortnext = p_sort->dw_sortnext; }
- else
+
+ if( p_tinfo->dw_linesort[i_element] == p_sort->dw_id )
{ p_tinfo->dw_linesort[i_element] = p_sort->dw_sortnext; }
p_sort->dw_sortnext = INVALID_LINE;
assert( NULL != p_tinfo );
assert( 0 < p_tinfo->dw_sections );
-
+/*
if( 0 != (p_tinfo->dw_maxline % p_tinfo->dw_sect_steps) )
{ return; }
-
+*/
p_sbefore = SECINFO(p_tinfo, dw_secid);
dw_secid++;
for( ; dw_secid < p_tinfo->dw_sections; dw_secid++ ) {
assert( NULL != p_tinfo );
assert( 0 < p_tinfo->dw_sections );
-
+/*
if( 0 != (p_tinfo->dw_maxline % p_tinfo->dw_sect_steps) )
{ return; }
-
+*/
p_section = p_tinfo->p_section + (p_tinfo->dw_sections - 1);
p_section->dw_line = 0;
p_section->dw_linfoid = INVALID_LINE;
p_line = LINFO(p_tinfo, p_tinfo->dw_line_end );
assert( NULL != p_line );
- 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 0x01; }
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 0x01; }
}
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++;
{ p_section->dw_line--; }
}
+ if( 0 != ((p_tinfo->dw_maxline - 1) % p_tinfo->dw_sect_steps) )
+ { goto goto_LibEditText_Section_DeleteLine_post; }
+
// Delete Section Info ---
p_section = SECINFO(p_tinfo, dw_secid);
if( 0 < dw_secid ) {
#define LIBEDITTEXT_SECTION_INTERNALFUNC extern
#endif
-#define CALC_LINE2SECTION(m,n) (((n)+1)/(m)->dw_sect_steps)
-#define CALC_SECTION2LINE(m,n) ((1 >= (m)->dw_sections) ? 0 : ((((m)->dw_maxline)*(n))/((m)->dw_sections - 1)))
-//#define CALC_SECTION2LINE(m,n) ((((m)->dw_maxline)*(n))/((m)->dw_sections))
+#define CALC_LINE2SECTION(m,n) ((n)/(m)->dw_sect_steps)
+#define CALC_SECTION2LINE(m,n) (((m)->dw_sect_steps)*(n))
#define SECINFO(m,n) ((m)->p_section+(n))
CU_ASSERT( 0x00 == i_result );
}
+ i_result = LibEditText_Debug_DebugTextInfo( i_tinfoid, 0x02);
+ CU_ASSERT( 0x00 == i_result );
+
+ for( i_cnt = 65536; i_cnt > 2; i_cnt-- ) {
+ i_result = LibEditText_DeleteLine_toLine( i_tinfoid, i_cnt );
+ CU_ASSERT( 0x00 == i_result );
+ }
+
i_result = LibEditText_Debug_DebugTextInfo( i_tinfoid, DEBUG_TEXTINFO_OUTPUT );
CU_ASSERT( 0x00 == i_result );
{
int i_result;
int i_tinfoid;
- int i_len;
- int i_cnt;
- char str_testdata[256];
i_result = LibEditText_Init();
CU_ASSERT( 0x00 == i_result );
i_result = LibEditText_InsertLine_toLine( i_tinfoid, 0, " 0: InsertLine Test00_001\n", 26);
CU_ASSERT( 0x00 == i_result );
- i_result = LibEditText_InsertLine_toLine( i_tinfoid, 3, " 2: InsertLine Test00_001", 25);
+ i_result = LibEditText_InsertLine_toLine( i_tinfoid, 2, " 2: InsertLine Test00_001", 25);
CU_ASSERT( 0x00 == i_result );
i_result = LibEditText_Debug_DebugTextInfo( i_tinfoid, DEBUG_TEXTINFO_OUTPUT );
CU_ASSERT( 0x00 == i_result );
for( i_cnt = 1022; i_cnt > 0; i_cnt-- ) {
- i_len = snprintf( str_testdata, 255, "%6d Dr.deamon64 libeditext testdata---\n", i_cnt);
+ i_len = snprintf( str_testdata, 255, "%6d Dr.deamon64 libeditext InsertLine2---\n", i_cnt);
i_result = LibEditText_InsertLine_toLine( i_tinfoid, 1, str_testdata, i_len);
CU_ASSERT( 0x00 == i_result );
}
-/*
- i_result = LibEditText_InsertLine_toLine( i_tinfoid, 1022, "Section TestData", 16);
- CU_ASSERT( 0x00 == i_result );
-*/
+
i_result = LibEditText_Debug_DebugTextInfo( i_tinfoid, DEBUG_TEXTINFO_OUTPUT );
CU_ASSERT( 0x00 == i_result );
CU_add_test( pt_edittext, "EditText_API_AppendLine_test00_001",
Test_LibEditText_API_AppendLine_test00_001 );
-
CU_add_test( pt_edittext, "EditText_API_InsertLine_test00_001",
Test_LibEditText_API_InsertLine_test00_001 );
CU_add_test( pt_edittext, "EditText_API_InsertLine_test00_002",
Test_LibEditText_API_InsertLine_test00_002 );
-
return 0x00;
}