BaCon - Bash-based Basic-to-C converter/compiler

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#391 Post by vovchik »

Dear puppians,

@ Joe
getting a test run example going with just BaCon and HUG
Thanks. There is no HUG - just straight calls to gtk/gdk, which makes the code more efficient and smaller. The down side of ths approach is that it looks almost like C, but that's OK if it gets the job done.:) I think I am finally ready to modify Picona, since I already have routines worked out for scaling and overlay. It's now a matter of reviewing my old Picona code and making the changes. It will be a small, single binary in the end, which is what I am after, and will run on any Linux/Unix with GTK installed. I just have to sit down and do it.

@ jpeps
I just dragged the two images onto the canvas
In my demo, in creating the final image, the 3D image is not on top but on the bottom, and the clear orb is on top - the overlay. The reason that the 3D is visible is because of the alpha transparency in the orb. That's why it looks better - apart from the scaling issue. :) Moreover, the merged image canvas (background) in the new image is transparent. I am fairly certain that wjaguar will include this capability in a new version of mtpaint, so we just have to wait a bit.

With kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#392 Post by jpeps »

wjaguar wrote:
jpeps wrote:I just dragged the two images onto the canvas and saved. (vovchik's looks better, though :) )
Precisely. And it is because mtPaint cannot properly read in "image2.png", which uses a palette with partial transparency (the first such image I've ever seen).
Yeah, I cheated and filled in the hole with paint for image3 :)

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#393 Post by jpeps »

vovchik wrote: In my demo, in creating the final image, the 3D image is not on top but on the bottom, and the clear orb is on top - the overlay. The reason that the 3D is visible is because of the alpha transparency in the orb. That's why it looks better
Converted the image2.png to a jpg first so it was more workable.
Attachments
image5.png
(10.42 KiB) Downloaded 1210 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#394 Post by vovchik »

Dear jpeps,

The reason jpg images are never used for icons is because they, by design, have no transparency. The "object" in the centre will always be accompanied by a background of some sort and there will be some dithering with respect to colours. There is, moreover, no alpha channel. Using jpgs for icons is, on the whole, a non-starter unless you add a transparent background and then remove the existing colour around an object and save back in a format that recognizes transparency such as png. Xpm images do have transparency, but they are limited in the number of colours they can display. Mac OSX icns and M$ ico support transparency and millions of colours, too, but for *nix, the standard is png or svg (for vector graphics).

With kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#395 Post by jpeps »

Very interesting, vovchik. mtPaint isn't recognizing the transparency format, so maybe that's why the jpg format looked better...although it comes with a backround, as you noted. A gif transformation (which also supports an alpha channel) looked the same as png.

You can create the transparency with the "opacity" slider in the layers window (as I did in my post) , although the background is part of the object.

It looks like your experiment will lead to some mtPaint development by wjaguar. (wow...he doesn't miss anything! :) )

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#396 Post by big_bass »

here is an update of bacon2bbc
It was bacon2bbc but since this is modified lets use bacon2bb

it now reduces the code 400 lines by using a DATA command

I want to comment that GatorDog was kind enough to show me
quite a few ways to improve the code from a PM he sent
I havent used all of his suggestions because
I need to keep it as simple as possible *so I understand what I'm doing* and at the same time
using the good ideas (the other ideas I will apply to my future snippets though so thanks rod )

there is a basic progress view now just dots but... hey
the linux kernel does that too :D

I will keep at this I am writing a script to do this faster so more to come
but its complete for practical use for adding color to the forum posts
and simple enough for a code example to hack at
Attachments
bacon2bb.tar.gz
(19.4 KiB) Downloaded 537 times
bb.png
(8.56 KiB) Downloaded 1137 times
Last edited by big_bass on Sat 22 Oct 2011, 21:16, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

bb code listing

#397 Post by vovchik »

Dear Joe,

I appreciate what you are trying to do - make code listings more readable - but the "[quote]" solution seems to have its own problems. While the color coding is great, "[quote]" eliminates all leading white space, so far as I can tell, which means all structural indentation disappears. The "

Code: Select all

" directive preserves the structure a bit by converting tabs into single spaces but, alas, has no color. BB code does not seem to  allow for the best of both worlds, unfortunately, so it is either colors for keywords and no structure or structure and no colored keywords. I have tried all sorts of combinations to get something working in a BB sandbox [url]http://www.bbcode.org/playground.php[/url] and have failed. Any ideas or workarounds?

With kind regards,
vovchik

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#398 Post by big_bass »

double post
Last edited by big_bass on Sat 22 Oct 2011, 13:52, edited 1 time in total.

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#399 Post by big_bass »

Hey vovchick
but the "
" solution seems to have its own problems. While the color coding is great, "
" eliminates all leading white space, so far as I can tell, which means all structural indentation disappears.
Any ideas or workarounds?

well ,yes there are quite a few solutions

we have user side solutions and server side solutions

since I can only do what a user can do that limits my options
but there is a java script code reader plug in for PhpBB that does color code but it doesnt allow for BaCon
code but all the work with bacon2bb will help simplify things converting the plugin to display color for BaCon
and HUG keywords


but then it would be easier to just take a screeny with mtpaint of the geany code :)
since we now have BaCon and Hug highlighting for that

I was trying to get SciTE to do Bacon and HUG keywords that would allow you to export to html
then a link could be made this does work for bash code though

somewhere in all of this a solution will be found that is simple light and doesnt fry any brain cells
getting it to work completely :D

I can make a bb html converter like this example but a link would be still be needed to point to the code
uploaded somewhere
seems the best of both words for forum viewing of color

http://www.bbcode-to-html.com/

one quick example
http://www.puppy2.org/slaxer/bacon2bb.html

a big file example
http://www.puppy2.org/slaxer/hug-colored.html


*remember that we are adding an option to something not built in to the original phpBB code
so from that point we just have workarounds


Joe
Last edited by big_bass on Wed 02 Nov 2011, 15:17, edited 1 time in total.

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

bacon2bb

#400 Post by big_bass »

Rod @GatorDog and I
have been working on bacon2bb

and I changed the author to authors :D
'--- AUTHORS: big_bass Joe Arose + rod the GatorDog '

when you convert BB code to html it looks like this
http://www.puppy2.org/slaxer/bacon2bb.html

http://www.puppy2.org/slaxer/bacon2bb-2 ... 1_SLXR.tgz
I packaged it just to make it easy to install

the editable files and source are in /etc/BaCon
you can easily add remove or modify HUG or BaCon keyords
because they are outside the binary and just plain text files now


@Hey vovchik
http://www.bbcode.org/examples/?id=15

Rendering some text (mostly code) while maintaining all white spacing and indentation within. Also uses a monospaced font (each character takes up the same space).

Joe
Attachments
with-color-and-comments.png
(9.89 KiB) Downloaded 1299 times

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#401 Post by big_bass »

bacon2html UPDATED NOV -28-2011
taking your *.bac BaCon code and adding keyword highlighting color
in html format so that you can post your BaCon / HUG code
anywhere 8-)

no middle step needed converts directly to html
http://www.puppy2.org/slaxer/bacon2html-2-6_SLXR.tgz

*I posted this in the BaCon forum
thought that puppy users would be interested too
with this same idea any coding language could be made into html color keywords
without all the php or java, CSS and gtksource view stuff
just keeping things simple and light
Last edited by big_bass on Tue 29 Nov 2011, 16:16, edited 1 time in total.

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#402 Post by big_bass »

found a cheat to make indentations
I did a lot of searching for this BBcode hack
it converts the underscore to white so when you quote its invisible :D
can you see the white line ?
_____

I placed a space before the first left bracket so you could see the code here
[ color=#FAFAFA]_____[/color]

the forum uses #DEE3E6 for the background grey
_____hover over with the mouse to see this just before the word hover

__


here you can see with code

OPEN "/etc/BaCon/bacon-keywords-data.txt" FOR READING AS myfile
WHILE NOT(ENDFILE(myfile)) DO
__ READLN txt$ FROM myfile
__ IF NOT(ENDFILE(myfile)) THEN
__ SYSTEM CONCAT$("replace " , " -e" , " '", txt$ ,"' " , " '", "<span style=","\"color: Indigo;","\">",txt$,"</span>", "' " , copy_this$,".html")
__ PRINT ".";
__ ENDIF
WEND
CLOSE FILE myfile
Last edited by big_bass on Sun 20 Nov 2011, 23:19, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#403 Post by vovchik »

Dear Joe,

That is CLEVER!!!

With kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#404 Post by jpeps »

big_bass wrote:found a cheat to make indentations
I did a lot of searching for this BBcode hack
it converts the underscore to white so when you quote its invisible :D
can you see the white line ?
_____
Yes :)

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#405 Post by big_bass »

indentbb

do you want to conserve space indentation with bb code ?
it can be automated with a compiled standalone bin
http://basic-converter.proboards.com/in ... thread=183

Joe
Last edited by big_bass on Tue 29 Nov 2011, 17:19, edited 1 time in total.

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#406 Post by big_bass »


big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#407 Post by big_bass »

html tools

indenthtml
compliment to bacon2html
it pre indents the html

it could be used as a stand alone for any file or code
it doesnt have to be bacon code
it auto indents justifies in spaces of five



Code: Select all


'--- ***************************************************** '
'--- PROGRAM:	indenthtml.bac '
'--- PURPOSE:	indent  html code  '
'--- AUTHOR:	big_bass Joe Arose   '
'--- DEPENDS:	gcc, bacon,  '
'--- PLATFORM:	linux '
'--- DATE:		Nov-28-2011'
'--- NOTES:	   
'--- LICENSE:	GPL version 3 or later '
'--- *****************************************************'

'--- this is only for modifing of code with justified indentation
'--- USUAGE: ./indenthtml /path-and-filename" ---'
'--- note the file will get a .indent added to the filename ---'
'--- on error print usage ---'
'--- this part was added to for variables to be passed at command line ---'


TRAP LOCAL
SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim
IF LEN(arg$[1]) EQ 0 THEN
     PRINT "USUAGE:  ./indenhtml /path-and-filename"
     END
END IF

Tab$ = CHR$(9)
FIVE_BLANKS$ = SPC$(5)

'--- Non-Breaking Space ---'

'--- set the default line indents ---'
FIVE_SPACES$ = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
TEN_SPACES$ = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
FIFTEEN_SPACES$ = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
TWENTY_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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
FIFTY_SPACES$= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
FIFTY_FIVE_SPACES$= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"


'--- copy_this$ is the first argument passed from the command line ---'
'--- path-and-filename is arg$[1] this is a valid bacon argument ---'
'--- give it a string name for clarity  ---'
copy_this$ = arg$[1]


'--- another code snippet from GatorDog thanks ---'
IF ISFALSE(FILEEXISTS(copy_this$)) THEN
     PRINT NL$, "=>> ", copy_this$, " <<== not found."
     PRINT "Please check your directory for assistance ;>)", NL$
END FALSE
END IF



'--- thanks  GatorDog ---'
COPY copy_this$ TO CONCAT$(copy_this$,".indent")



'--- Rename working file to TMP ext.
RENAME CONCAT$(copy_this$,".indent") TO CONCAT$(copy_this$,".indentTMP")
OPEN CONCAT$(copy_this$,".indent") FOR WRITING AS my_outfile
OPEN CONCAT$(copy_this$,".indentTMP") FOR READING AS my_infile
WHILE NOT(ENDFILE(my_infile))
     READLN txt$ FROM my_infile


     '--- pre step replace tabs with five spaces ---'
     txt$ = REPLACE$(txt$, Tab$, FIVE_BLANKS$)


     '--- check if line of text starts with spaces or tabs ---'
     IF REGEX(txt$, "^ ") OR REGEX(txt$, "^FIVE_BLANKS$") THEN
          PRINT "Yep, ", txt$, "--> starts with spaces !"
          PRINT
          PRINT
          full_count = LEN(txt$)

          '--- a chop left is used here to remove only left spaces ---'
          chopped_count = LEN(CHOP$(txt$," ",1))
          start_space_count = full_count - chopped_count

          '--- error checking ---'
          '--- blue is ok yellow is error with a limit of 55 spaces ---'
          IF start_space_count < 53 THEN
               PRINT "you have ";
               COLOR FG TO BLUE
               PRINT  start_space_count," leading space(s)"
               COLOR RESET

          ELSE
               PRINT "you have ";
               COLOR FG TO YELLOW
               PRINT  start_space_count," leading space(s)"
               COLOR RESET
          END IF


          '--- start main ---'
          IF start_space_count < 3 THEN
               PRINT "will chop off this < 3 spaced indented  "
               PRINT CHOP$(txt$," ",1)
               WRITELN CHOP$(txt$," ",1) TO my_outfile
          END IF


          IF start_space_count >= 3  AND  start_space_count <= 6 THEN
               PRINT "will shift you to five so it looks good   "
               PRINT FIVE_SPACES$, txt$
               WRITELN FIVE_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 7 AND start_space_count <= 12 THEN
               PRINT "will shift you  to ten so it looks good   "
               PRINT TEN_SPACES$, txt$
               WRITELN TEN_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 13 AND start_space_count <= 17 THEN
               PRINT "will shift you  to fifteen so it looks good   "
               PRINT FIFTEEN_SPACES$, txt$
               WRITELN FIFTEEN_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 18 AND start_space_count <= 22 THEN
               PRINT "will shift you  to twenty so it looks good   "
               PRINT TWENTY_SPACES$, txt$
               WRITELN TWENTY_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 23 AND start_space_count <= 27 THEN
               PRINT "will shift you  to twenty five so it looks good "
               PRINT TWENTY_FIVE_SPACES$, txt$
               WRITELN TWENTY_FIVE_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 28 AND start_space_count <= 32 THEN
               PRINT "will shift you  to thirty  so it looks good   "
               PRINT THIRTY_SPACES$, txt$
               WRITELN THIRTY_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 33 AND start_space_count <= 37 THEN
               PRINT "will shift you  to thirty five so it looks good "
               PRINT THIRTY_FIVE_SPACES$, txt$
               WRITELN THIRTY_FIVE_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 38 AND start_space_count <= 42 THEN
               PRINT "will shift you  to forty so it looks good   "
               PRINT FORTY_SPACES$, txt$
               WRITELN FORTY_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 43 AND start_space_count <= 47 THEN
               PRINT "will shift you  to forty five so it looks good  "
               PRINT FORTY_FIVE_SPACES$, txt$
               WRITELN FORTY_FIVE_SPACES$, txt$ TO my_outfile
          END IF


          IF start_space_count  >= 48 AND start_space_count <= 52 THEN
               PRINT "will shift you  to fifty so it looks good   "
               PRINT FIFTY_SPACES$, txt$
               WRITELN FIFTY_SPACES$, txt$ TO my_outfile
          END IF

          '--- if over 53 spaces force all 55 spaces  ---'
          IF start_space_count > 53 THEN
               PRINT "ERROR more than 53 spaces indented  you have "  ;
               COLOR FG TO RED
               PRINT start_space_count ,"  indent limit 55 forced !"
               COLOR RESET
               WRITELN FIFTY_FIVE_SPACES$, txt$ TO my_outfile
          END IF


     ELSE
          PRINT "no leading spaces "
          PRINT txt$
          WRITELN txt$ TO my_outfile
     WEND
END IF
CLOSE FILE my_infile
CLOSE FILE my_outfile
DELETE FILE CONCAT$(copy_this$,".indentTMP")


PRINT
PRINT
PRINT "The indent conversion is done!"
PRINT copy_this$,".indent", "  <--- is the modified file "

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#408 Post by sunburnt »

Hi guys... I just installed Puppy528 and BaConGUI won`t run a file. :(

Error: Could not open library ./hug.so: cannot open shared object file: No such file or directory

hug.so is in: /usr/share/BaCon as usual.
Don`t know why it`s looking in the current dir.
I`m sure it`s something simple I`m missing...

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#409 Post by big_bass »

bb2bbpress
http://www.puppy2.org/slaxer/bb2bbpress-1.0-4_SLXR.tgz

a command line tool that converts murga forum to puppylinux.info code
in technical terms phpBBcode to bbpress code

so you can pass your posts to puppylinux.info
and back up your valuable data there

written in pure BaConwhich compiles in C code so its fast fast
already compiled and packaged the source is included as always
if you look at my txz thread you can see the results of running the tool
it is 95% working correctly in automatically correcting the code

the other 5%
what doesnt work are all those http bla bla see here links
they look neater but they are terrible to convert from one forum to another and should be avoided
the full url is the best format for passing threads from one forum to another

and the list ,list = I still have to do some more testing on that to get it to convert to bbpress format

enjoy



you must be the author of the thread
open your thread you want to edit on murga
select all the text then save it to a file
at the command line type
bb2bbpress /the name of the file to correct
then paste *.bbpress-fixed in puppylinux.info

Joe
Last edited by big_bass on Mon 05 Dec 2011, 16:23, edited 3 times in total.

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#410 Post by GatorDog »

Error: Could not open library ./hug.so: cannot open shared object file: No such file or directory
Hey Sunburnt,

How is your IMPORT statement in your program set up?

GatorDog
Image

Post Reply