hedgewars/uChat.pas
changeset 10845 1dbd50690951
parent 10844 953d85b7d529
child 10846 c76fd416eff6
equal deleted inserted replaced
10844:953d85b7d529 10845:1dbd50690951
   616     // remaining ascii are special chars
   616     // remaining ascii are special chars
   617     exit(special);
   617     exit(special);
   618 end;
   618 end;
   619 
   619 
   620 // skip from word to word, similar to Qt
   620 // skip from word to word, similar to Qt
   621 procedure skipInputChars(skip: TCharSkip; backwards: boolean);
   621 procedure SkipInputChars(skip: TCharSkip; backwards: boolean);
   622 begin
   622 begin
   623 if backwards then
   623 if backwards then
   624     begin
   624     begin
   625     // skip trailing whitespace, similar to Qt
   625     // skip trailing whitespace, similar to Qt
   626     while (skip = wspace) and (cursorPos > 0) do
   626     while (skip = wspace) and (cursorPos > 0) do
   677     case Sym of
   677     case Sym of
   678         SDLK_BACKSPACE:
   678         SDLK_BACKSPACE:
   679             begin
   679             begin
   680             if selectedPos < 0 then
   680             if selectedPos < 0 then
   681                 begin
   681                 begin
   682                 // remove char before cursor (note: cursorPos is 0-based, char idx isn't)
   682                 if ctrl then
       
   683                     skip:= GetInputCharSkipClass(cursorPos);
       
   684 
       
   685                 // remove char before cursor
   683                 dec(cursorPos, DelCharFromInputStr(cursorPos));
   686                 dec(cursorPos, DelCharFromInputStr(cursorPos));
       
   687 
       
   688                 // delete more if ctrl is held
       
   689                 if ctrl and (selectedPos < 0) then
       
   690                     begin
       
   691                     HandleSelection(true);
       
   692                     SkipInputChars(skip, true);
       
   693                     DeleteSelected();
       
   694                     end;
   684                 end
   695                 end
   685             else
   696             else
   686                 DeleteSelected();
   697                 DeleteSelected();
   687             UpdateCursorCoords();
   698             UpdateCursorCoords();
   688             end;
   699             end;
   692                 begin
   703                 begin
   693                 // remove char after cursor
   704                 // remove char after cursor
   694                 if cursorPos < Length(InputStr.s) then
   705                 if cursorPos < Length(InputStr.s) then
   695                     begin
   706                     begin
   696                     DoCursorStepForward();
   707                     DoCursorStepForward();
       
   708                     if ctrl then
       
   709                         skip:= GetInputCharSkipClass(cursorPos);
       
   710 
       
   711                     // delete char
   697                     dec(cursorPos, DelCharFromInputStr(cursorPos));
   712                     dec(cursorPos, DelCharFromInputStr(cursorPos));
       
   713 
       
   714                     // delete more if ctrl is held
       
   715                     if ctrl and (cursorPos < Length(InputStr.s)) then
       
   716                         begin
       
   717                         HandleSelection(true);
       
   718                         SkipInputChars(skip, false);
       
   719                         DeleteSelected();
       
   720                         end;
   698                     end;
   721                     end;
   699                 end
   722                 end
   700             else
   723             else
   701                 DeleteSelected();
   724                 DeleteSelected();
       
   725 
   702             UpdateCursorCoords();
   726             UpdateCursorCoords();
   703             end;
   727             end;
   704         SDLK_ESCAPE:
   728         SDLK_ESCAPE:
   705             begin
   729             begin
   706             if Length(InputStr.s) > 0 then
   730             if Length(InputStr.s) > 0 then
   779                     cursorPos:= min(cursorPos, selectedPos);
   803                     cursorPos:= min(cursorPos, selectedPos);
   780                     ResetSelection();
   804                     ResetSelection();
   781                     end;
   805                     end;
   782 
   806 
   783                 if ctrl then
   807                 if ctrl then
   784                     skipInputChars(skip, true);
   808                     SkipInputChars(skip, true);
   785 
   809 
   786                 UpdateCursorCoords();
   810                 UpdateCursorCoords();
   787                 end;
   811                 end;
   788             end;
   812             end;
   789         SDLK_RIGHT:
   813         SDLK_RIGHT:
   801                     cursorPos:= max(cursorPos, selectedPos);
   825                     cursorPos:= max(cursorPos, selectedPos);
   802                     ResetSelection();
   826                     ResetSelection();
   803                     end;
   827                     end;
   804 
   828 
   805                 if ctrl then
   829                 if ctrl then
   806                     skipInputChars(GetInputCharSkipClass(cursorPos), false);
   830                     SkipInputChars(GetInputCharSkipClass(cursorPos), false);
   807 
   831 
   808                 UpdateCursorCoords();
   832                 UpdateCursorCoords();
   809                 end;
   833                 end;
   810             end;
   834             end;
   811         SDLK_PAGEUP, SDLK_PAGEDOWN:
   835         SDLK_PAGEUP, SDLK_PAGEDOWN: