OSDN Git Service

* WorkBackup: 2015/05/20(Wed) AM 05:35 (Implementing LibEditText_Section_AvoidanceInL...
authorKoine Yuusuke(koinec) <koinec@users.sourceforge.jp>
Tue, 19 May 2015 20:36:20 +0000 (05:36 +0900)
committerKoine Yuusuke(koinec) <koinec@users.sourceforge.jp>
Tue, 19 May 2015 20:36:20 +0000 (05:36 +0900)
libedittext/drd64_libedittext_section.c

index e1cf9f9..5db010f 100644 (file)
@@ -454,6 +454,60 @@ int
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
+DWord
+       LibEditText_Section_AvoidanceInLineSection(
+                       LibEditText_TextInfo    *p_tinfo,
+                       DWord   dw_line,
+                       DWord   dw_secid )
+{
+       DWord   dw_cnt;
+       DWord   dw_ret;
+       LibEditText_LineSection *p_section;
+       LibEditText_LineInfo    *p_line;
+
+       p_section       = SECINFO(p_tinfo, dw_secid);
+       assert( NULL != p_section );
+
+       dw_ret  = dw_secid;
+
+       if( p_section->dw_line < dw_line )
+               { return dw_ret + 1; }
+       else if( p_section->dw_line > dw_line )
+               { assert( 0 ); /* ERROR!! - NO exit function!! */ }
+       
+       /* follow statement is if( dw_line == p_section->dw_line ) */
+
+       for( dw_cnt = dw_secid; dw_cnt > 0; dw_cnt-- )  {
+
+               p_section       = SECINFO(p_tinfo, dw_cnt);
+               assert( NULL != p_section );
+
+               if( p_section->dw_line != dw_line )     { break; }
+
+               p_line  = LINFO(p_tinfo, p_section->dw_linfoid);
+
+               if(( 0 < dw_cnt ) && ( 0 < dw_line ))           {
+                       p_line  = LINFO(p_tinfo, p_line->dw_before);
+                       assert( NULL != p_line );
+                       p_section->dw_line              = dw_line - 1;
+                       p_section->dw_linfoid   = p_line->dw_id;
+
+                       dw_ret  = dw_secid + 1;
+               }
+               else if( dw_line + 1 < p_tinfo->dw_maxline )    {
+                       p_line  = LINFO(p_tinfo, p_line->dw_next);
+                       assert( NULL != p_line );
+                       p_section->dw_line              = dw_line + 1;
+                       p_section->dw_linfoid   = p_line->dw_id;
+               }
+       }
+
+       return dw_ret;
+}
+
+                       
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
 LIBEDITTEXT_SECTION_EXTERN
 void
        LibEditText_Section_DeleteLine(
@@ -480,7 +534,7 @@ void
                                                                p_tinfo, dw_secid, dw_line );
        }
 
-       p_section       = SECINFO(p_tinfo, dw_secid);
+/*     p_section       = SECINFO(p_tinfo, dw_secid);
        assert( NULL != p_section );
 
        if( dw_line == p_section->dw_line )             {
@@ -509,8 +563,10 @@ void
        }
 
        dw_cnt  = dw_secid + 1;
+*/
+       dw_cnt  = LibEditText_Section_AvoidanceInLineSection( p_tinfo, dw_line, dw_secid );
 
-goto_LibEditText_Section_DeleteLine_lineup:
+//goto_LibEditText_Section_DeleteLine_lineup:
 /*     if( dw_line != p_section->dw_line )
                { dw_cnt        = dw_secid + 1; }
        else