*/}}
Pārlūkot izejas kodu

Fix cut operation

YimingWu 3 mēneši atpakaļ
vecāks
revīzija
9945913242
2 mainītis faili ar 27 papildinājumiem un 13 dzēšanām
  1. 1 0
      la_interface.h
  2. 26 13
      resources/la_widgets.c

+ 1 - 0
la_interface.h

@@ -1462,6 +1462,7 @@ typedef int (*laSystemFunc)(laOperator *, laEvent *);
 #define LA_CONFIRM_IGNORE (1<<12)
 #define LA_CONFIRM_DATA (1<<13)
 #define LA_CONFIRM_CUSTOM_STRING (1<<14)
+#define LA_CONFIRM_TEXT_EDIT (1<<15)
 
 STRUCTURE(laOperatorType){
     laListItem Item;

+ 26 - 13
resources/la_widgets.c

@@ -1056,15 +1056,16 @@ void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedThe
     tnsUseNoTexture();
     if (!strHasSelection(se)){
         tnsColor4dv(laAccentColor(LA_BT_TEXT));
-        int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + LA_M;
-        tnsVertex2d(L-1, U + LA_RH - LA_M);
-        tnsVertex2d(L-1, U + LA_M);
-        tnsVertex2d(L+2, U + LA_M);
-        tnsVertex2d(L+2, U + LA_RH - LA_M);
+        int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin;
+        int CW=LA_M;
+        tnsVertex2d(L-CW, U + LA_RH - LA_M);
+        tnsVertex2d(L-CW, U + LA_M);
+        tnsVertex2d(L+CW, U + LA_M);
+        tnsVertex2d(L+CW, U + LA_RH - LA_M);
         tnsPackAs(GL_TRIANGLE_FAN);
     }else{
-        int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + LA_M;
-        int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + LA_M;
+        int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin;
+        int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin;
         tnsColor4dv(laAccentColor(LA_BT_NORMAL));
         tnsVertex2d(L, U + LA_M);
         tnsVertex2d(L, U + LA_RH - LA_M);
@@ -1182,15 +1183,17 @@ void la_MultiStringDraw(laUiItem *ui, int h){
             int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen; 
             BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
             tnsUseNoTexture();
-            tnsVertex2d(BeginC*MonoWidth+_L, LineU);     tnsVertex2d(EndC*MonoWidth+_L, LineU);
-            tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
+            int UseL=BeginC*MonoWidth+_L, UseR=EndC*MonoWidth+_L;
+            TNS_CLAMP(UseL, _L, ui->R); TNS_CLAMP(UseR, _L, ui->R);
+            tnsVertex2d(UseL, LineU);     tnsVertex2d(UseR, LineU);
+            tnsVertex2d(UseR, LineU+LA_RH); tnsVertex2d(UseL, LineU+LA_RH);
             tnsColor4dv(laAccentColor(LA_BT_NORMAL));
             tnsPackAs(GL_TRIANGLE_FAN);
         }
         int len=strlenU(sl->Buf); 
         if(UseLine==se->CursorLine){
             int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
-            tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth; real w2=LA_RH/12;
+            tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth; int w2=LA_M;
             tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
             tnsVertex2d(_L+Dist-w2-d, LineU); tnsVertex2d(_L+Dist+w2-d, LineU);
             tnsVertex2d(_L+Dist-w2-d, LineU+LA_RH); tnsVertex2d(_L+Dist+w2-d, LineU+LA_RH);
@@ -1207,8 +1210,6 @@ void la_MultiStringDraw(laUiItem *ui, int h){
         char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
         tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_BORDER),ui->L, ui->R-LA_RH, ui->B-LA_M-LA_RH, LA_TEXT_MONO|LA_TEXT_ALIGN_RIGHT);
     }
-    
-    //if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
 
     tnsFlush();
 }
@@ -2293,7 +2294,7 @@ int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
     char* str=strGetEditString(uit->Edit, 1);
     laCopyToClipboard(str); free(str);
 
-    if(strSame(mode,"CUT")){ strClearSelection(&uit->Edit); }
+    if(strSame(mode,"CUT")){ strClearSelection(uit->Edit); laConfirmInt(a,0,LA_CONFIRM_TEXT_EDIT); return LA_FINISHED_PASS; }
 
     return LA_FINISHED;
 }
@@ -2491,6 +2492,9 @@ int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
 
     if (uit->Edit){
         if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
+        if (a->ConfirmData){
+            if(a->ConfirmData->Mode == LA_CONFIRM_TEXT_EDIT){ laRedrawCurrentPanel(); }
+        }
         return LA_RUNNING;
     }
 
@@ -2619,6 +2623,9 @@ int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
 
     if (uit->Edit){
         if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
+        if (a->ConfirmData){
+            if(a->ConfirmData->Mode == LA_CONFIRM_TEXT_EDIT){ laRedrawCurrentPanel(); }
+        }
         return LA_RUNNING;
     }
 
@@ -3084,6 +3091,9 @@ int OPMOD_SingleLineString(laOperator *a, laEvent *e){
                 buf=strGetEditString(uit->Edit,0); laSetString(&ui->PP, buf); free(buf);
             }
         }
+        if (a->ConfirmData){
+            if(a->ConfirmData->Mode == LA_CONFIRM_TEXT_EDIT){ laRedrawCurrentPanel(); }
+        }
         return LA_RUNNING;
     }
 
@@ -3178,6 +3188,9 @@ int OPMOD_MultiString(laOperator *a, laEvent *e){
 
     if (ui->State == LA_UI_ACTIVE){
         if (la_ProcessTextEdit(e, se, ui))laRedrawCurrentPanel();
+        if (a->ConfirmData){
+            if(a->ConfirmData->Mode == LA_CONFIRM_TEXT_EDIT){ laRedrawCurrentPanel(); }
+        }
         return LA_RUNNING;
     }