Forum > Editor

[SOLVED] Caret shape

(1/2) > >>

YiannisKam:
Hello, does anybody know how to change the caret's shape inside the editor from a vertical line to a block?

Martin_fr:
If you are using SynEdit, and you are writing your own app:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    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:
Hi Martin, I've seen an old post of yours https://forum.lazarus.freepascal.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:
If you look at the setter for the property

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      FScreenCaret.DisplayType := FInsertCaret

YiannisKam:
I found this

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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;

Navigation

[0] Message Index

[#] Next page

Go to full version