Recent

Author Topic: [Solved] Handling long lines in source with Lazarus IDE editor  (Read 7331 times)

markusd112

  • New Member
  • *
  • Posts: 18
[Solved] Handling long lines in source with Lazarus IDE editor
« on: December 27, 2015, 07:40:23 am »
Hi,

as there any option in the lazarus source code editor to wrap long lines?

Or is there any possibility to write a long source code text row in multiplex rows?

In other languages it works with an "\" at the end of the line, e.g.

char* s = "sfgsdfg \
    asdfasdf\
    sadfsdf";

Or sometimes with an "_" at the beginning. But in freepascal it doesn't seem to work.

Some code editors have an option to handle long lines, which is for me the most comfortable way to code...

Thanks,

Markus
« Last Edit: December 27, 2015, 08:41:33 am by markusd112 »

balazsszekely

  • Guest
Re: Handling long lines in source with Lazarus IDE editor
« Reply #1 on: December 27, 2015, 07:43:58 am »
Did you try "+"? Like this:
Code: Pascal  [Select][+][-]
  1. var
  2.   s: string;
  3. begin
  4.   s := 'aaaaaaaaaaaaaaaaaaa' +
  5.        'bbbbbbbbbbbbbbbbbbb' +
  6.        'ccccccccccccccccccccccccc';
  7. end;
  8.  

markusd112

  • New Member
  • *
  • Posts: 18
Re: Handling long lines in source with Lazarus IDE editor
« Reply #2 on: December 27, 2015, 08:14:20 am »
Great, that works. Thanks!!  :) 

But with code lines other than strings (e.g. a long if statement) there is no possibility to handle long lines...

Am I right, that there is no switch in the editor preferences to enable some sort of line wrap directly in the editor to handle long lines?

Best regards

Markus

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Handling long lines in source with Lazarus IDE editor
« Reply #3 on: December 27, 2015, 08:37:22 am »
you are in pascal now where the crlf is not considered end of statement eg
Code: Pascal  [Select][+][-]
  1.       if (i = QueryList.Count - 1) or
  2.          ((Trim(QueryList[i + 1]) <> '') and  (Pos('/*', Trim(QueryList[i + 1])
  3.            ) <> 1) and
  4.          (Pos('--', Trim(QueryList[i + 1])) <> 1)) then
  5.           Break;
  6.  
which you can write as
Code: Pascal  [Select][+][-]
  1.       if (i
  2.           =
  3.           QueryList.Count
  4.           -
  5.           1)
  6.           or
  7.           (
  8.           (Trim(
  9.                 QueryList[i + 1]
  10.                )
  11.            <>
  12.            '')
  13.            and
  14.            (Pos(
  15.                 '/*',
  16.                 Trim(
  17.                      QueryList[i + 1]
  18.                     )
  19.                 )
  20.             <>
  21.             1
  22.            )
  23.            and
  24.          (Pos('--', Trim(QueryList[i + 1])) <> 1)) then Break;  
  25.  
with out problems except the readability one that is.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

markusd112

  • New Member
  • *
  • Posts: 18
Re: Handling long lines in source with Lazarus IDE editor
« Reply #4 on: December 27, 2015, 08:40:26 am »
Ah ok, thanks. Now it is clear to me :).

I tried the same with a string const (nearly like the C example in the initial post) and that didn't work like this. But with the "+" solution it works for strings.

Thanks for your help!

Best regards

Markus

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12205
  • Debugger - SynEdit - and more
    • wiki
Re: [Solved] Handling long lines in source with Lazarus IDE editor
« Reply #5 on: December 27, 2015, 10:00:36 am »
The editor can also auto continue strings or comments.

Menu / Tools / options / editor / general / tab + indent.

If enabled and you press return while inside a string, it will add   ' + at the end of line, and ' at the start of the new line.

markusd112

  • New Member
  • *
  • Posts: 18
Re: [Solved] Handling long lines in source with Lazarus IDE editor
« Reply #6 on: December 28, 2015, 07:06:54 am »
That's a good hint, thanks. :)

@edit: I tried to find this option, but in my Lazarus IDE it isn't available? The problem is, that I am using the german version of the IDE, so the texts differ. But there seems to bo no such option in the Editor --> general preferences...
See attached screenshot...

Bye,
Markus
« Last Edit: December 28, 2015, 07:15:26 am by markusd112 »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12205
  • Debugger - SynEdit - and more
    • wiki
Re: [Solved] Handling long lines in source with Lazarus IDE editor
« Reply #7 on: December 28, 2015, 09:31:06 am »
2nd picture.

there are buttons: "ansi", ..., "string"

 

TinyPortal © 2005-2018