FBeauty.bas, a Geany custom command for code beautyfying

User projects written in or related to FreeBASIC.
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

FBeauty.bas, a Geany custom command for code beautyfying

Postby TJF » Oct 17, 2010 17:05

FBeauty.bas is the source for a FreeBasic code beautyfier. It acts like a filter, identyfying FreeBasic keywords in the input streem (stdin) and replaces them by their upper-case equivalents in the output stream (stdout). All other words and characters are not filtered at all. The filter does neither work in comments nor in strings.

The program has been developed for use in Geany, an FreeBasic-IDE for LINUX and win. As a compiled binary it can be added in Geany as a 'sent text' custom command. Just go to the 'Set Custom Commands' dialog in the 'Format' sub menu of the 'Edit' and 'Popup' menu. Then click on 'Add' to get a new text entry and type the command for calling the FBeauty binary. From now on, the current selection can be sent to FBeauty and the filtered output of FBeauty will be used to replace the current selection.

FBeauty can also be used at the command line by reading the input from a file. E. g. on LINUX type
    ./FBeauty < Input.txt > Output.bas
to read the context form Input.txt and write it filtered to Output.bas.

The filter features of FBeauty.bas may get adapted for personal purposes.

Download: https://github.com/DTJF/FBeauty

Have fun!

[Edit]
Hosting provider updated (new since version 1.01).
[/Edit]
Last edited by TJF on Mar 24, 2015 16:21, edited 1 time in total.
jdebord
Posts: 504
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Postby jdebord » Oct 18, 2010 9:31

It works very well. Thanks!
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Postby TJF » Oct 21, 2010 11:29

I fixed a small bug: now it works for single words as well. (Download link in first post.)

jdebord wrote:It works very well. Thanks!

Thanks for feedback, enjoy!
E.K.Virtanen
Posts: 785
Joined: May 28, 2005 9:19
Location: Finland

Postby E.K.Virtanen » Oct 23, 2010 5:38

Looks neat. Reminds me about c2x converter i made with a friend for yabasic. It makes xhtml file with syntax colors of a yabasic code file.

http://www.basicprogramming.org/ekv/by_me.php#codes
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Postby TJF » Jun 20, 2011 20:08

New version 0.0.2 uploaded.
  • bugfixes and extensions in keyword list
  • new command line options
      default is upper case keywords
      -l = lower case keywords
      -c = capitalized keywords
      -i = individual case keywords (as defined in source code)
Download (as in first post):
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re:

Postby TJF » May 25, 2012 10:21

New version 0.0.4 uploaded.
  • bugfixes and extensions in keyword list
  • new support for escaped STRINGs

Download (as in first post):
Roland Chastain
Posts: 733
Joined: Nov 24, 2011 19:49
Location: Dakar, Senegal
Contact:

Re: FBeauty.bas, a Geany custom command for code beautyfying

Postby Roland Chastain » Jul 24, 2013 0:03

Hello TJF !

I played for one or two hours with your nice program. I didn't manage to configure correctly Geany, but I wrote a batch file. With your permission I paste it here.

Code: Select all

@echo off
rem BeautifyDirectory.bat
rem Batch script for FBeauty
rem http://www.freebasic-portal.de/downloads/ides-fuer-freebasic/fbeauty-bas-160.html

rem 1° All .bas files in srcdir are renamed to .txt.
rem 2° FBeauty reads .txt files and creates new .bas files.
rem 3° All .txt files are deleted.

rem Tested under Windows XP.

set srcdir=C:\Atelier\Basic\Josephus
set fbtdir=C:\Atelier\Basic\FBeauty

cd %srcdir%
rename *.bas *.txt

cd %fbtdir%
for /R "%srcdir%" %%f in (*.txt) do (
  FBeauty -l < %%~f > %%~dpnf.bas
)

rem -l = lower case keywords
rem -c = capitalized keywords
rem -i = individual case keywords (as defined in source code)

goto FIN
rem Remove goto if you want the .txt files to be deleted.
cd %srcdir%
del /s/q *.txt

:FIN
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: FBeauty.bas, a Geany custom command for code beautyfying

Postby TJF » Jul 24, 2013 6:03

Hello Roland,

thanks for sharing your work! While the Geany installation is good to transform one file (or just parts of a file), your solution can handle a complete project (and more) at once. I hope your code will help windows users. (Do you consider to develop a cross-platform solution, ie as a small FB command line tool?)

Roland Chastain wrote:I didn't manage to configure correctly Geany, ...

Which Geany version do you use? (AFAIR you need at least Geany 0.16.)

BTW:
I use FBeauty to mark my code during the development process. Raw code in the first development stage is in lower case characters (typing is fast without using the SHIFT keys). Then, after I tested some code (a keyword, a line, a loop, a function, ...) I use FBeauty as a Geany filter to transform the keywords to upper case letters. So I can easily find out if a piece of code is reliable or not. (Unfortunatelly, when I see lower-case code here at the forum, I get the feeling it's raw, untested code :-(
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Update

Postby TJF » Aug 05, 2013 7:31

New version 0.90 uploaded.

  • keyword adaption for fbc-0.90
  • review of symbol names and comments

Download (as in first post):

TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

FBeauty for a complete folder

Postby TJF » Aug 05, 2013 7:44

Just for cross-linking:

TJF wrote:(Do you consider to develop a cross-platform solution, ie as a small FB command line tool?)


Roland finished his tool. It can be found here

TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

FBeauty.bas: new release, new hosting provider

Postby TJF » Mar 24, 2015 16:19

Version 1.01 is out:

  • Keyword list updated (effective fbc-1.01)
  • No more change of member variables like 'atype.width' or 'atype->width'

Download now at

srvaldez
Posts: 1354
Joined: Sep 25, 2005 21:54

Re: FBeauty.bas, a Geany custom command for code beautyfying

Postby srvaldez » Jun 26, 2017 16:49

thank you TJF :-)
very useful.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 3 guests