Recent

Author Topic: [SOLVED] Special Question - LAZ IDE Code - SynEdit  (Read 1880 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1269
[SOLVED] Special Question - LAZ IDE Code - SynEdit
« on: May 13, 2019, 02:35:15 am »
I have been trying to figure out how to Print SynEdit text using the Printer.Canvas, and I have been having trouble.

But, it dawned on me that the LAZ IDE "File/Print" menu function does just that. (even using the Print dialog - which I want to use too)

So, I opened up the LAZ source code project and tried to find the code the IDE uses to print the SynEdit text (aka the source editor)

I went through the some 40-50 files in the project trying to it, can't find it.

Does anybody know what pp or pas file that code will be in??



« Last Edit: May 13, 2019, 09:53:28 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

jamie

  • Hero Member
  • *****
  • Posts: 7891
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #1 on: May 13, 2019, 04:00:18 am »
Well as I see it,

You have the SynEdit

Then you use a Highligher for the synEdit of your choice...

Then you can use the TSynExportHTml which needs the highlighter.
 
Basically, exporter can generate a HTML script using the highlighter plugin and the SynEdit uses the same highlighter..

The team did very well with this component I must say... :)
The only true wisdom is knowing you know nothing

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #2 on: May 13, 2019, 12:18:52 pm »
That's nice, but don't want html output, I am trying to find the code they use to print the code in the IDE editor (synEdit) window,
I want to be able to print to the Printer Canvas, which is what I believe they are doing in the IDE.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12616
  • Debugger - SynEdit - and more
    • wiki
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #3 on: May 13, 2019, 03:02:39 pm »
Not sure, but I believe it is in the package "Printer4LazIde"
The file components\printers\design\sourceprinter.pas

SourcePrinter.Execute(SynEdit.Lines);

It is called from
components\printers\design\ideprinting.pas

It does not have an option for colors or highlight....

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #4 on: May 13, 2019, 03:12:46 pm »
Not sure, but I believe it is in the package "Printer4LazIde"
The file components\printers\design\sourceprinter.pas

SourcePrinter.Execute(SynEdit.Lines);

It is called from
components\printers\design\ideprinting.pas

It does not have an option for colors or highlight....

Thanks... that is fine, don't need colors or highlights.

Just want to print plain old text

I will check it out.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #5 on: May 13, 2019, 03:24:33 pm »
Is this it???
Looks like it

Code: Pascal  [Select][+][-]
  1. procedure TSourcePrinter.PrintPage(Text: TStrings; PageNum: integer);
  2. var
  3.   l: integer;
  4.   s: string;
  5.   LineNum, PrintNum: integer;
  6. begin
  7.   //print all lines on the current page
  8.   for l := 0 to LinesPerPage - 1 do
  9.   begin
  10.     LineNum := Pred(PageNum) * LinesPerPage + l;
  11.  
  12.     //check if end of text is reached
  13.     if LineNum < Text.Count then
  14.     begin
  15.       PrintNum := PtrUInt(Text.Objects[LineNum]);
  16.       if ShowLineNumbers then begin
  17.         if (PrintNum > 0) then
  18.           s := Format('%4d: ',[PrintNum])
  19.         else
  20.           s := '      ';
  21.         end
  22.       else
  23.         s := '';
  24.  
  25.       s := s + Text[LineNum];
  26.  
  27.       Printer.Canvas.TextOut(Margin, Round(LineHeight * l), s);
  28.     end;
  29.   end;
  30. end;
  31.  
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #6 on: May 13, 2019, 07:38:02 pm »
@MARTIN...

Amazingly I got it to work. (see screen below)

Only issue is that I set the MARGIN to 50, and the left right & bottom works great, but the TOP doesn't

It is like that too when you print from the LAZ IDE.

How is the Top margin handled in the IDE code.
I see the the MARGIN code, but nothing about the left.

FYI... I didn't print the line numbers.
« Last Edit: May 13, 2019, 07:40:23 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Special Question - LAZ IDE Code - SynEdit
« Reply #7 on: May 13, 2019, 09:53:10 pm »
Got the SynEdit prject working.

Here is the thread where I was working on this.

https://forum.lazarus.freepascal.org/index.php/topic,45382.0.html
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

 

TinyPortal © 2005-2018