Recent

Author Topic: Lazarus indenter is not so smart  (Read 3462 times)

Yiyuan

  • New Member
  • *
  • Posts: 11
Lazarus indenter is not so smart
« on: June 26, 2020, 08:26:03 am »
Hi, friends. I am a newbie to Lazarus family. When I used the source editor, I encountered some problems with the indenter. I hope some expert can help me.

First, when I enter the comments and compiler progmas, the editor can not automatically add the matching curly brace. I didn't find the options.

Second, if I continue entering the "procedure" after a "type" block, there will be an indentation. I think "procedure" should be in the same level as "type", right? What's more,  when I create a simple console program from the template, if I did not manually indent "procedure" , the editor will not automatically add matching "end;" after the "begin". I found the problem arose from the template's default "begin end.". If I deleted them, the editor worked correctly. Or if I manually indent the "begin" ("begin" is in the same indentation level as "prodedure in default), the indenter also worked.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}{$J-}
  2. program Learning_notes;
  3.  
  4. procedure simpetest;
  5. begin
  6.  
  7. begin
  8.  
  9. end.

Third, when I just minimize the source editor window (not minimize the whole lazarus) and reopen it later, the source editor window will automatically occupy the full screen. not in the origin size. Maybe it is a bug.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Lazarus indenter is not so smart
« Reply #1 on: June 26, 2020, 10:11:37 am »
First, when I enter the comments and compiler progmas, the editor can not automatically add the matching curly brace. I didn't find the options.

That is already on the wish list.

Yiyuan

  • New Member
  • *
  • Posts: 11
Re: Lazarus indenter is not so smart
« Reply #2 on: June 27, 2020, 12:51:44 pm »
Thanks!

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: Lazarus indenter is not so smart
« Reply #3 on: June 27, 2020, 04:50:22 pm »
Not sure if the indentation issue you're having is exactly what this solves, but I know when I install a new fpc / laz then the first thing I do is go into the options search for "indentation" and turn off "smart tabs". I don't exactly remember the behavior they do, but I remember leaving that setting on makes me swear at my computer a few times.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus indenter is not so smart
« Reply #4 on: June 27, 2020, 06:43:41 pm »
[...] and turn off "smart tabs". . I don't exactly remember the behavior they do, but I remember leaving that setting on makes me swear at my computer a few times.

IIRC, "Smart Tabs" means that when you press <TAB> the IDE inserts as many "tabs" as needed to let the cursor at the same position than the next "word" of the previous line, so if, for example, you have a multiline assignment statement you can then move the second (and next) lines so that they align with the first after the ":="

What the OP is seeing is the auto-indent not being able to read minds and not knowing that you have ended with a type section (or whatever). Auto-indent is really simple: it just puts the cursor of a new line at the same indentation level that the previous and leaves it there; nothing more. Problem then is that auto-completion sometimes gets a little lost and forgets to add an "end" afer you type a "begin"[CR] if the indentation is not entirely "correct" :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: Lazarus indenter is not so smart
« Reply #5 on: June 27, 2020, 07:55:02 pm »
Nicely put :)

Yiyuan

  • New Member
  • *
  • Posts: 11
Re: Lazarus indenter is not so smart
« Reply #6 on: June 29, 2020, 10:32:02 am »
I searched the wiki and found that "Fully automatic indentation tries to guess the rules from the surrounding code. It does that by searching for similar code and copying the indent." But I can not understand what it means.
https://wiki.lazarus.freepascal.org/Fully_automatic_indentation

TRon

  • Hero Member
  • *****
  • Posts: 2434
Re: Lazarus indenter is not so smart
« Reply #7 on: June 29, 2020, 11:02:03 am »
I searched the wiki and found that "Fully automatic indentation tries to guess the rules from the surrounding code. It does that by searching for similar code and copying the indent." But I can not understand what it means.
https://wiki.lazarus.freepascal.org/Fully_automatic_indentation
"Any Way the Wind Blows"

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus indenter is not so smart
« Reply #8 on: June 29, 2020, 06:24:03 pm »
I searched the wiki and found that "Fully automatic indentation tries to guess the rules from the surrounding code. It does that by searching for similar code and copying the indent." But I can not understand what it means.
https://wiki.lazarus.freepascal.org/Fully_automatic_indentation

Read the whole page; it's explained quite well ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Yiyuan

  • New Member
  • *
  • Posts: 11
Re: Lazarus indenter is not so smart
« Reply #9 on: July 02, 2020, 08:52:10 am »
Thanks. After reading it thoroughly, I think I grasp the principles. I must apologize for my carelessness.

 

TinyPortal © 2005-2018