View Issue Details

IDProjectCategoryView StatusLast Update
0027258PatchesPatchpublic2015-01-26 12:29
ReporterBBaz Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Fixed in Version1.3 (SVN) 
Summary0027258: Add a "CaseSensitive" property to TSynPluginSyncroEdit
DescriptionTSynPluginSyncroEdit may be used in a software used to edit a case-sensitive language.

It would not be possible to implement the feature in a derivated class because some things must be added in the private methods Scan() and StartSyncroMode(), hence 99% of the current implementation would have to be copied from TSynPluginSyncroEdit into a new TSynPluginCustomSyncroEdit derivated class.
TagsNo tags attached.
Fixed in Revision47346
LazTarget1.4
Widgetset
Attached Files

Activities

BBaz

2015-01-06 04:06

reporter  

patch.diff (2,879 bytes)   
diff --git a/components/synedit/synpluginsyncroedit.pp b/components/synedit/synpluginsyncroedit.pp
index 583e5be..7534c5a 100644
--- a/components/synedit/synpluginsyncroedit.pp
+++ b/components/synedit/synpluginsyncroedit.pp
@@ -41,6 +41,7 @@ type
 
   TSynPluginSyncroEditLowerLineCache = class
   private
+    FCaseSensitive: boolean;
     FLines: TSynEditStrings;
     FLower: Array of TSynPluginSyncroEditLowerLineCacheEntry;
     function GetLowLine(aIndex: Integer): String;
@@ -187,6 +188,7 @@ type
 
   TSynPluginSyncroEdit = class(TSynPluginCustomSyncroEdit)
   private
+    FCaseSensitive: boolean;
     FGutterGlyph: TBitmap;
     FLowerLines: TSynPluginSyncroEditLowerLineCache;
     FOnBeginEdit: TNotifyEvent;
@@ -250,6 +252,7 @@ type
     class function ConvertBaseToCommand(Command: TSynEditorCommand): TSynEditorCommand;
 
   published
+    property CaseSensitive: boolean read FCaseSensitive write FCaseSensitive default false;
     property GutterGlyph: TBitmap read FGutterGlyph write SetGutterGlyph;
     property KeystrokesSelecting: TSynEditKeyStrokes
       read FKeystrokesSelecting write SetKeystrokesSelecting;
@@ -341,8 +344,10 @@ begin
   for i := 0 to l-1 do
     if FLower[i].LineIndex = aIndex then
       exit(FLower[i].LineText);
-
-  Result := UTF8LowerCase(FLines[aIndex]);
+  if FCaseSensitive then
+    Result := FLines[aIndex]
+  else
+    Result := UTF8LowerCase(FLines[aIndex]);
   if Result = '' then
     exit;
   if l < MAX_CACHE then begin
@@ -883,6 +888,7 @@ var
   Line: String;
 begin
   Result := AFrom;
+  FLowerLines.FCaseSensitive := FCaseSensitive;
   if BackWard then begin
     Line := FLowerLines[AFrom.y - 1];
     while (AFrom >= aTo) do begin
@@ -983,6 +989,7 @@ var
   Line: String;
 begin
   Result := AFrom;
+  FLowerLines.FCaseSensitive := FCaseSensitive;
   if BackWard then begin
     Line := FLowerLines[AFrom.y - 1];
     while (AFrom > aTo) do begin
@@ -1057,6 +1064,7 @@ begin
   Markup.GlyphAtLine := Pos.y;
 
   g := 1;
+  FLowerLines.FCaseSensitive := FCaseSensitive;
   Line := FLowerLines[Pos.y-1];
   while (Pos <= EndPos) do begin
     Pos.x :=  WordBreaker.NextWordStart(Line, Pos.x, True);
@@ -1156,6 +1164,7 @@ var
     if FParsedStart.y >= 0 then exit(True);
     y := NewPos.y;
     x := NewPos.x;
+    FLowerLines.FCaseSensitive := FCaseSensitive;
     while y <= NewEnd.y do begin
       x :=  WordBreaker.NextWordStart(FLowerLines[y-1], x, True);
       if (x > 0) and ((y < NewEnd.Y) or (x <= NewEnd.x)) then begin
@@ -1259,9 +1268,9 @@ end;
 procedure TSynPluginSyncroEdit.DoPreActiveEdit(aX, aY, aCount, aLineBrkCnt: Integer;
   aUndoRedo: Boolean);
 begin
-    FWordIndex.Clear;
-    Active := False;
-    Mode := spseInvalid;
+  FWordIndex.Clear;
+  Active := False;
+  Mode := spseInvalid;
 end;
 
 function TSynPluginSyncroEdit.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
patch.diff (2,879 bytes)   

Martin Friebe

2015-01-12 04:24

manager   ~0080303

Applied with some minor changes. (caching is not needed if lines are not changed to lowercase)

Please try not to include indentation changes in unrelated code.

Issue History

Date Modified Username Field Change
2015-01-06 04:06 BBaz New Issue
2015-01-06 04:06 BBaz File Added: patch.diff
2015-01-07 18:55 Martin Friebe Assigned To => Martin Friebe
2015-01-07 18:55 Martin Friebe Status new => assigned
2015-01-12 04:24 Martin Friebe Fixed in Revision => 47346
2015-01-12 04:24 Martin Friebe LazTarget => 1.4
2015-01-12 04:24 Martin Friebe Note Added: 0080303
2015-01-12 04:24 Martin Friebe Status assigned => resolved
2015-01-12 04:24 Martin Friebe Fixed in Version => 1.3 (SVN)
2015-01-12 04:24 Martin Friebe Resolution open => fixed
2015-01-26 12:29 BBaz Status resolved => closed