Recent

Author Topic: Listing text files, and opening them in another pane when clicked  (Read 1072 times)

Flight714

  • New Member
  • *
  • Posts: 13
Hi all,

I'm a beginner with FP and Lazarus but am heartened that my first basic app worked, just a Hello World really  :D

What I'm looking to do is immediately start on an app that would be useful for me. It would do the following:

  • Show a list of text files on the left (*.md Markdown format)
  • When one file is clicked, it is displayed on the right, for reading
  • Nice to have: Show sub-folders / allow navigation of files in the left side
  • Nice to have: Show an "edit" button on the right that opens the selected file in third-party editing software.

So far I am searching the forums for little tidbits of information. It has been a long time since I used Pascal, but I have done a reasonable amount of programming in other languages.

Any tips on which components to use for this, and where to look to learn about them, would be much appreciated. Thank you.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Listing text files, and opening them in another pane when clicked
« Reply #1 on: July 25, 2019, 05:03:37 am »
That would be just a TFileListBox or TShellTreeView to select files, a TMemo to view (or edit) them and a TButton+TProcess to launch an external editor. Fairly easy: You can have a prototype running in a few an hour.

ETA: You meant something like the attached image, didn't you? (Just a Q&D demo, won't attach the code) :)
« Last Edit: July 25, 2019, 05:56:45 am by lucamar »
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.

Flight714

  • New Member
  • *
  • Posts: 13
Re: Listing text files, and opening them in another pane when clicked
« Reply #2 on: July 25, 2019, 06:17:41 am »
That's very helpful, thank you. Neat to see the image as well. I was surprised to draw the TFileListBox component and see a list of files from my home directory appear.  :o :D

It seems I need to learn a 1) lot about syntax, coming from daily PHP and bash use, and 2) maybe play around with this OnChange event handler next; it seems promising.

I see a lot of Delphi results when I search for examples of the various handlers and objects in use; can I expect that code to be portable to my FP project?

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Listing text files, and opening them in another pane when clicked
« Reply #3 on: July 25, 2019, 02:26:43 pm »
It seems I need to learn a 1) lot about syntax, coming from daily PHP and bash use, and 2) maybe play around with this OnChange event handler next; it seems promising.

Playing around with code is the best way to learn. There are also lots of tutorials in the wiki and you may find some recomendations for outside ones by looking for "Turorial" in this forum. Whihc leads us to ...

Quote
I see a lot of Delphi results when I search for examples of the various handlers and objects in use; can I expect that code to be portable to my FP project?

In genreal yes; FP (and Lazarus) try to be as compatible as possible with Borland's Delphi. Although there are some differences there are (usually) not unsurmountable obstacles and one can easily work around the few you may find.

And as a last resource, if you find yourself down a deep pit from where you don't know how to escape, there's always this forum. Someone, somewhere, will probably know where the exit lies and won't mind sharing the trick. :)

Have luck!
« Last Edit: July 25, 2019, 02:31:08 pm by lucamar »
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.

Flight714

  • New Member
  • *
  • Posts: 13
Re: Listing text files, and opening them in another pane when clicked
« Reply #4 on: July 27, 2019, 12:26:36 am »
Thank you lucamar  :)

 

TinyPortal © 2005-2018