Recent

Author Topic: [SOLVED] how to change text selected to bold/italic  (Read 7412 times)

kyura

  • New member
  • *
  • Posts: 8
[SOLVED] how to change text selected to bold/italic
« on: December 30, 2011, 04:29:58 pm »
Greetings,

I have searched for this issue, but failed to find (understandable) answers.
Understandable because I am rather new to Free pascal/lazarus and the pascal notation.

to get into more details;

I am making a simple text editor to get familiar with the new syntax notations.
I have the most simple functionality liek file saving and loading, copy paste cut and such written.
I am stuck however on making the selected text in the SynEdit control bold.

If I bold the text in the SynEdit, I only manage to make the entire Text bold.
I have no clue how to accomplish this.

I know I can get the selected text, but what happens after?

I hope I can be helped with this issue. Thanks in advance.
Loving the language so far, and hoping for steady improvements in my skills.

Thus, tips and hints are also welcome! Thanks for reading :)
« Last Edit: December 30, 2011, 06:48:38 pm by kyura »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12123
  • Debugger - SynEdit - and more
    • wiki
Re: [SynEdit] how to change text selected to bold/italic
« Reply #1 on: December 30, 2011, 04:59:44 pm »
Depends on what you want to do...

1)
Highlighting the current selection in bold (instead of blue background)S
  SynEdit.SelectedColor.Style
However, that only lasts as long as the text is selected.

2)
Permanently changing the attributes of some part of the text:

It can be done, but involves some work.
Look in the example folder for SynPositionHighlighter. You need to track the start/end of each highlight yourself. (e.g. if the text is edited, you must change all positions)

Also note:
- You can change bold/italic/color
- You can NOT change the font size or font itself.
SynEdit does only one font for the entire doc.

kyura

  • New member
  • *
  • Posts: 8
Re: [SynEdit] how to change text selected to bold/italic
« Reply #2 on: December 30, 2011, 06:48:23 pm »
I see. I wanted to go for option 2.

Thank you for your answer.
Changing font's was not(yet) my plan, and won't be knowing the limitation.

I took a look at the example(after reading your answer), just a quick look at first to get the idea. And searched some online info.
I am quite sure I understand the idea.

Next step is the implementation.

However my question got answered and I will consider this solved.

Thanks again.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12123
  • Debugger - SynEdit - and more
    • wiki
Re: [SOLVED] how to change text selected to bold/italic
« Reply #3 on: December 30, 2011, 07:36:08 pm »
I don't know what you want to do, but maybe the RichMemo can help? Though I know nothing about it...

http://wiki.lazarus.freepascal.org/Special:Search?search=richmemo&go=Go


Code on how to move a start,end point, if text is edited is in syncro-edit and/or SynEditPointClasses
« Last Edit: December 30, 2011, 07:44:45 pm by Martin_fr »

kyura

  • New member
  • *
  • Posts: 8
Re: [SOLVED] how to change text selected to bold/italic
« Reply #4 on: December 30, 2011, 10:22:17 pm »
I read about that aswell, but I understood it has it's issues.
I got the illusion SynEdit was the way to go for text editors(excluding syntax highlighters)
because of its support for line numbers, and many options.

I will give it a try.
Thanks again

 

TinyPortal © 2005-2018