*/}}
Pārlūkot izejas kodu

multi string widget behaviour fix

YimingWu 3 mēneši atpakaļ
vecāks
revīzija
97d3e22063
2 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. 4 2
      la_util.c
  2. 4 2
      resources/la_widgets.c

+ 4 - 2
la_util.c

@@ -47,6 +47,7 @@ int strToUnicode(uint32_t* target, unsigned char* const src){
     uint32_t UC,adv,i=0; unsigned char* source=src; while(target[i]=laToUnicode(source, &adv)) { source+=adv; i++; } target[i]=0; return i;
 }
 int strToUTF8Lim(unsigned char* target, uint32_t* const src, int count){
+    if(count<=0){ return 0; }
     uint32_t* source=src; unsigned char* out=target; int i=0; while(laToUTF8(*source, out, &out)){ source++; i++; if(i>=count) break; } *out=0; return out-target;
 }
 int strToUTF8(unsigned char* target, uint32_t* const src){
@@ -1989,7 +1990,7 @@ void strBeginEdit(laStringEdit **se, char *FullStr){
         laStringLine *sl = memAcquireSimple(sizeof(laStringLine));
         lstAppendItem(&nse->Lines, sl); nse->TotalLines=1;
     }
-    laStringLine *sl = strGetCursorLine(nse, 0); int len=strlen(sl->Buf);
+    laStringLine *sl = strGetCursorLine(nse, 0); int len=strlenU(sl->Buf);
     if(len<nse->CursorBefore){ nse->CursorBefore=len; }
     *se=nse;
 }
@@ -2002,8 +2003,9 @@ char* strGetEditString(laStringEdit *se, int SelectionOnly){
         if(SelectionOnly && Line<se->BeginLine){ continue; }
         if(SelectionOnly && Line==se->BeginLine){ starti=se->BeginBefore; }
         int tlen=strlenU(&sl->Buf[starti]); int Extra=sl->Item.pNext?2:1;
+        if(SelectionOnly){ if(Line<se->EndLine){ Extra=2; }else{ Extra=1; } }
         arrEnsureLength(&result, (len+tlen)*4+Extra, &max, sizeof(char));
-        if(SelectionOnly && Line==se->EndLine){ endat=NextChar+se->EndBefore-starti; }
+        if(SelectionOnly && Line==se->EndLine){ endat=se->EndBefore-starti; }
         NextChar+=strToUTF8Lim(&result[NextChar], &sl->Buf[starti], endat); len+=tlen;
         if(Extra==2){ result[NextChar]='\n'; NextChar+=1; }
         if(SelectionOnly && Line==se->EndLine){ break; }

+ 4 - 2
resources/la_widgets.c

@@ -2294,7 +2294,9 @@ int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
     char* str=strGetEditString(uit->Edit, 1);
     laCopyToClipboard(str); free(str);
 
-    if(strSame(mode,"CUT")){ strClearSelection(uit->Edit); laConfirmInt(a,0,LA_CONFIRM_TEXT_EDIT); return LA_FINISHED_PASS; }
+    if(strSame(mode,"CUT")){ strClearSelection(uit->Edit); laConfirmInt(a,0,LA_CONFIRM_TEXT_EDIT);
+        laRedrawCurrentPanel(); return LA_FINISHED_PASS;
+    }
 
     return LA_FINISHED;
 }
@@ -3187,7 +3189,7 @@ int OPMOD_MultiString(laOperator *a, laEvent *e){
     }
 
     if (ui->State == LA_UI_ACTIVE){
-        if (la_ProcessTextEdit(e, se, ui))laRedrawCurrentPanel();
+        if (la_ProcessTextEdit(e, se, ui)) laRedrawCurrentPanel();
         if (a->ConfirmData){
             if(a->ConfirmData->Mode == LA_CONFIRM_TEXT_EDIT){ laRedrawCurrentPanel(); }
         }