[SOLVED] Caret shape lazarus / 9-Editor ---------------------------------------------------------------------- YiannisKam · 2024-03-15 19:38 Hello, does anybody know how to change the caret's shape inside the editor from a vertical line to a block? ---------------------------------------------------------------------- Martin_fr · 2024-03-15 20:39 If you are using SynEdit, and you are writing your own app: 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     property InsertCaret: TSynEditCaretType read FInsertCaret write SetInsertCaret default ctVerticalLine;    property OverwriteCaret: TSynEditCaretType read FOverwriteCaret write SetOverwriteCaret default ctBlock;  If you want to change it in the IDE => Sorry, but that isn't implemented. (Well, if you toggle "overwrite mode" with the insert key, then you get a block, but you will overwrite the existing text) You can change the carets color, in the IDE => in the color settings. However, the editor then draws a custom caret, and screen readers will not work well with that (though, if you care how the caret looks, I guess you don't use a screen reader) ---------------------------------------------------------------------- YiannisKam · 2024-03-15 21:08 Hi Martin, I've seen an old post of yours https://forum.lazarus.freepa scal.org/index.php/topic,14105.msg74420.html#msg74420 and wanted to experiment myself. Basically I made this change and rebuilt the ide: fInsertCaret := ctBlock;  //ctVerticalLine Now the caret can change shape but in order to do that, I have to press two times the insert key. First press changes to overwrite mode which I don't want, then I press twice for insert mode and the caret stays at the block shape as I want (figured that accidentally to be honest). Do you happen to know any 'hack' to have this block shape by default? Because it keeps reverting back to vertical line when I create a new project or I open a new unit. ---------------------------------------------------------------------- Martin_fr · 2024-03-15 21:13 If you look at the setter for the property 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       FScreenCaret.DisplayType := FInsertCaret ---------------------------------------------------------------------- YiannisKam · 2024-03-15 21:26 I found this 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 procedure TCustomSynEdit.SetInsertMode(const Value: boolean);begin  if fInserting <> Value then begin    fInserting := Value;    if InsertMode then      FScreenCaret.DisplayType := FInsertCaret    else      FScreenCaret.DisplayType := FOverwriteCaret;    StatusChanged([scInsertMode]);  end;end; procedure TCustomSynEdit.SetInsertCaret(const Value: TSynEditCaretType);begin  if FInsertCaret <> Value then begin    FInsertCaret := Value;    if InsertMode then      FScreenCaret.DisplayType := fInsertCaret;    StatusChanged([scOptions]);  end;end; procedure TCustomSynEdit.SetOverwriteCaret(const Value: TSynEditCaretType);begin  if FOverwriteCaret <> Value then begin    FOverwriteCaret := Value;    if not InsertMode then      FScreenCaret.DisplayType := fOverwriteCaret;    StatusChanged([scOptions]);  end;end; ---------------------------------------------------------------------- Martin_fr · 2024-03-15 22:05 I am assuming your initial change was in the SynEdit constructor? Then just setting the field directly will not update the value in ScreenCaret. So have you added the line to update that too? You can also use the property, but then you need to set the field to its original default first, so in the property the new value will be different. ---------------------------------------------------------------------- YiannisKam · 2024-03-15 22:25 I've only changed the value inside the constructor. Further on, I don't know what to do. ---------------------------------------------------------------------- Martin_fr · 2024-03-15 22:29 Quote from: YiannisKam on March 15, 2024, 11:25:27 pmI've only changed the value inside the constructor. Further on, I don't know what to do. After you changed it, insert the line 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   fInsertCaret := ctBlock; // your changed line  FScreenCaret.DisplayType := fInsertCaret; // add this ---------------------------------------------------------------------- YiannisKam · 2024-03-15 22:39 Wonderful, just wonderful. Thank you so much