[SOLVED] Capitalizing the Editor lazarus / 9-Editor ---------------------------------------------------------------------- mosquito · 2023-07-18 10:50 I'm experimenting with how to capitalize the entire editor. I've made good progress, but I still have a big problem. The options I have used are: [JCF Format Settings] Obfuscation -> All Capitalize options Capitalization -> All Options Asm -> All Capital [CodeTools] Words -> Keyword Policy | Identification Policy So far, everything perfect, the initial template, insert automatic code from the events tab, double click on items in the Object Inspector, etc. The big problem is with code completion (after '.' , CTRL+Space, Etc.) If anyone has any ideas how this could be done I would be very grateful. ---------------------------------------------------------------------- Martin_fr · 2023-07-18 11:28 I don't have ideas how to make completion use upper case (unless, maybe if you convert all sources (lcl, rtl, ...) to uppercase? But you have seen: menu > Edit > Uppercase selection ? (Just select-all, and then...) Will include strings, though... Otherwise write yourself a macro in Pascal script. (see editormacros / wiki) ---------------------------------------------------------------------- mosquito · 2023-07-18 11:38 Quote from: Martin_fr on July 18, 2023, 01:28:41 pmI don't have ideas how to make completion use upper case (unless, maybe if you convert all sources (lcl, rtl, ...) to uppercase? But you have seen: menu > Edit > Uppercase selection ? (Just select-all, and then...) Will include strings, though... Otherwise write yourself a macro in Pascal script. (see editormacros / wiki) I hope it is not necessary to do so much plumbing. I have no problem displaying the suggestions in CamelCase. I even have no problem using the hints just as a visual aid and writing the code by hand. The problem is that once the suggestion timer is triggered, even if you write the code by hand, when you press RETURN the entire sentence is converted to CamelCase. So if I find the routine that governs that RETURN I think I could add a procedure to convert the insertion to uppercase letters... but I can't find it !! ---------------------------------------------------------------------- mosquito · 2023-07-18 11:41 Thanks for the suggestion of the macros, I'll check, thank you very much. ---------------------------------------------------------------------- Martin_fr · 2023-07-18 15:12 Quote from: mosquito on July 18, 2023, 01:38:59 pmI have no problem displaying the suggestions in CamelCase. I even have no problem using the hints just as a visual aid and writing the code by hand. The problem is that once the suggestion timer is triggered, even if you write the code by hand, when you press RETURN the entire sentence is converted to CamelCase. So if I find the routine that governs that RETURN I think I could add a procedure to convert the insertion to uppercase letters... but I can't find it !! If you want to make changes for your personal IDE: Maybe (not tested) before display in the list     components\codetools\identcompletiontool.pas     line 890     procedure TIdentifierList.Add(NewItem: TIdentifierListItem); uppercase NewItem.Identifier.    procedure TSynCompletion.Validate(Sender: TObject; KeyChar: TUTF8Char;    components\synedit\syncompletion.pas    line 1885 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i           Value := ItemList[Position];            FOnCodeCompletion(Value, TextBetweenPoints[NewBlockBegin, NewBlockEnd],                            NewBlockBegin, NewBlockEnd, KeyChar, Shift);  uppercase "Value" For other completions (afaik code templates) look at  class  TSourceEditCompletion in ide/sourceeditor.pas ---------------------------------------------------------------------- mosquito · 2023-07-18 16:33 Testing... Many many thanks !! ---------------------------------------------------------------------- mosquito · 2023-07-18 20:10 Although I have not had good results so far, it is evident that we are touching the right place, since I have managed to break the execution of the autocompletion or insert a blank statement. I am investigating around the second option that you mention, there are things that I do not understand: ../lazarus_stable/lazarus/components/synedit/syncompletion.pas tested with all "rebuild-ide" flavours. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  if Assigned(FOnCodeCompletion) then          begin            Value := ItemList[Position];{-----> At this point (Value = 'Dummy') ??? ; From here, any UPPERxx(value) or value.ToUpper = 'DUMMY'--}            FOnCodeCompletion(Value, TextBetweenPoints[NewBlockBegin, NewBlockEnd],                              NewBlockBegin, NewBlockEnd, KeyChar, Shift);            if (CompareCarets(NewBlockBegin, NewBlockEnd) <> 0) or (Value <> '') then            ...            ...          end else begin            TextBetweenPointsEx[NewBlockBegin, NewBlockEnd, scamEnd] := ItemList[Position];{-----> At this point (Value = '') ; But ItemList[Position] too. ---}//???             TCustomSynEdit(F.CurrentEditor).SetFocus;            .... ---------------------------------------------------------------------- Martin_fr · 2023-07-18 21:08 I can't test it right now. So I can only look at the related sources. procedure TSourceEditCompletion.ccComplete(var Value: string; in ide/SourceEditor.pp Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ctIdentCompletion:...            // get value            NewValue:=GetIdentCompletionValue(Self, KeyChar, ValueType, CursorToLeft);            if ValueType=icvIdentifier then ;          // insert value plus special chars like brackets, semicolons, ...          if ValueType <> icvNone then              Editor.TextBetweenPointsEx[SourceStart, SourceEnd, scamEnd] := NewValue;  should be NewValue before the call to TextBetweenPointsEx. ---------------------------------------------------------------------- mosquito · 2023-07-19 10:07 Me and my Dyslexia, we are very grateful to you. This is going to make my writing very relaxed. You can't imagine (I hope). With all these suggestions I have the editor fully capitalized. I'm sure there will be more things to play, but for now for a coding session it's perfect for me. Thanks again. ---------------------------------------------------------------------- Martin_fr · 2023-07-19 11:25 Ah, there is a good explanation for this. If interested, the patch below will make the editor show everything uppercased. (for utf8 you may need to change UpperCase...) It will keep the text as it is, so if you save it, and others open it, the text will be as it was. If you type, you add upper/lowercase according to shift, but you see all uppercase. Completion dropdown is not affected... But the values inserted will be shown uppercase. Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/components/synedit/synedittextbuffer.pp b/components/synedit/synedittextbuffer.ppindex 96d62ca40b..15d6246b7d 100644--- a/components/synedit/synedittextbuffer.pp+++ b/components/synedit/synedittextbuffer.pp@@ -124,6 +124,8 @@   TLazSynDisplayBuffer = class(TLazSynDisplayViewEx)   private     FBuffer: TSynEditStringList;     FAtLineStart: Boolean;+    FCurLine: array of String;+    FCurLineIdx: integer;   public     constructor Create(ABuffer: TSynEditStringList);     procedure SetHighlighterTokensLine(ALine: TLineIdx; out ARealLine: TLineIdx; out AStartBytePos, ALineByteLen: Integer); override;@@ -393,6 +395,8 @@ procedure TLazSynDisplayBuffer.SetHighlighterTokensLine(ALine: TLineIdx; out   AStartBytePos := 1;   ALineByteLen := Length(FBuffer[ARealLine]);   FAtLineStart := True;+  FCurLineIdx := 0;+  SetLength(FCurLine, 100); end;  function TLazSynDisplayBuffer.GetNextHighlighterToken(out ATokenInfo: TLazSynDisplayTokenInfo): Boolean;@@ -400,10 +404,15 @@ function TLazSynDisplayBuffer.GetNextHighlighterToken(out ATokenInfo: TLazSynDis   Result := False;   if not Initialized then exit; +  inc(FCurLineIdx);+  if FCurLineIdx >= Length(FCurLine) then SetLength(FCurLine, FCurLineIdx+50);+   if CurrentTokenHighlighter = nil then begin     Result := FAtLineStart;     if not Result then exit;-    ATokenInfo.TokenStart := FBuffer.GetPChar(CurrentTokenLine, ATokenInfo.TokenLength);+    FCurLine[FCurLineIdx] := UpperCase(FBuffer[CurrentTokenLine]);+    ATokenInfo.TokenStart := PChar(FCurLine[FCurLineIdx]);+    ATokenInfo.TokenLength := Length(FCurLine[FCurLineIdx]);     ATokenInfo.TokenAttr := nil;     FAtLineStart := False;   end@@ -421,7 +430,9 @@ function TLazSynDisplayBuffer.GetNextHighlighterToken(out ATokenInfo: TLazSynDis       exit;     end; -    CurrentTokenHighlighter.GetTokenEx(ATokenInfo.TokenStart, ATokenInfo.TokenLength);+    FCurLine[FCurLineIdx] := UpperCase(CurrentTokenHighlighter.GetToken);+    ATokenInfo.TokenStart := PChar(FCurLine[FCurLineIdx]);+    ATokenInfo.TokenLength := Length(FCurLine[FCurLineIdx]);     ATokenInfo.TokenAttr := CurrentTokenHighlighter.GetTokenAttribute;     CurrentTokenHighlighter.Next;   end;  However, if you copy (and paste outside synedit) text then it will be upper/lower as the original. Also any dialog (like search/replace) will act on the original. ---------------------------------------------------------------------- mosquito · 2023-07-19 18:19 I understand how it works. It's a great gift. Now I have 2 great things, although they don't behave the same. But with so much power in my hands now it's time to combine both, because one is very good for writing but bad for third parties (somewhat selfish). And the second option is a great solution for reading, diving into dependent units, and good for third parties. But it generates a little stress not knowing if the invisible copy was written correctly (strings, unix file system that is case sensitive, etc, etc). Also very easy to correct. In principle I will use a combination of two instances. One with the code completer mods and one with the highlighter mods. Surely you can make a balanced use of both. Really thanks.