BaCon - Bash-based Basic-to-C converter/compiler
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
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
taking your *.bac BaCon code and adding keyword highlighting color
in html format so that you can post your BaCon / HUG code
anywhere
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.
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
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
I did a lot of searching for this BBcode hack
it converts the underscore to white so when you quote its invisible
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.
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
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.
bacon2html UPDATED NOV -28-2011
http://www.murga-linux.com/puppy/viewto ... &start=400
I will keep it updated here
http://basic-converter.proboards.com/in ... thread=179
http://www.murga-linux.com/puppy/viewto ... &start=400
I will keep it updated here
http://basic-converter.proboards.com/in ... thread=179
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
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$ = " "
TEN_SPACES$ = " "
FIFTEEN_SPACES$ = " "
TWENTY_SPACES$ = " "
TWENTY_FIVE_SPACES$ = " "
THIRTY_SPACES$= " "
THIRTY_FIVE_SPACES$= " "
FORTY_SPACES$= " "
FORTY_FIVE_SPACES$= " "
FIFTY_SPACES$= " "
FIFTY_FIVE_SPACES$= " "
'--- 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 "
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...
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...
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
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.
Hey GatorDog; Same as always...
Is there something that is setup upon installing BaCon ( I don`t recall any...)?
I thought BaCon hard coded the file path /usr/share/BaCon/hug.so
Code: Select all
INCLUDE "/usr/share/BaCon/hug_imports.bac"
I thought BaCon hard coded the file path /usr/share/BaCon/hug.so
Code: Select all
sh-4.1# find /usr/share/BaCon/h*.so
/usr/share/BaCon/hug.so
Still the same error: Could not open library ./hug.so
/usr/share/BaCon/hug_imports.bac
I see why the error says ./hug.so ( the original CONST declare ).
But why didn`t it change with my two edits?
/usr/share/BaCon/hug_imports.bac
Code: Select all
' Imports when HUG is used as shared object
'CONST HUG_lib$ = "./hug.so"
'CONST HUG_lib$ = "/usr/share/BaCon/hug.so"
CONST HUG_lib$ = "/usr/lib/hug.so"
But why didn`t it change with my two edits?
Hey sunburnt
hug.so is a run time dependency
this means you can move it around
to debug where it needs to be
which is determined by what was used at compile time
if you place hug.so in the same directory as your compiled bin
which is the bacon gui
it will work
you can recompile placing
hug.so where you want
but to maintain a standard
it should be placed in /usr/lib
move it around till it works
then recompile
Joe
hug.so is a run time dependency
this means you can move it around
to debug where it needs to be
which is determined by what was used at compile time
if you place hug.so in the same directory as your compiled bin
which is the bacon gui
it will work
you can recompile placing
hug.so where you want
but to maintain a standard
it should be placed in /usr/lib
move it around till it works
then recompile
Joe
Can`t remember if this has been asked/answered yet...
How to get pixel width of a string to set width of buttons, etc.
A tricky thing as it has to do with font, font size, bold, and italic.
A simple fix would be to use only mono-spaced fonts.
btnWidth = character count + pixels per character + padding
In V.B. I use to just have a hidden text box with the "snap to size" set.
So I`d fill it with text and read it`s width property.
# If a MARK could be made and set it`s "snap to size" property...
How to get pixel width of a string to set width of buttons, etc.
A tricky thing as it has to do with font, font size, bold, and italic.
A simple fix would be to use only mono-spaced fonts.
btnWidth = character count + pixels per character + padding
In V.B. I use to just have a hidden text box with the "snap to size" set.
So I`d fill it with text and read it`s width property.
# If a MARK could be made and set it`s "snap to size" property...
pixel width
Dear Terry,
It is possible with pango, but you will have to recode this bit in BaCon (not hard):
If I have time, I will do this and make it a BaCon function. If you have time and do it first, please post it.
With kind regards,
vovchik
PS. Here is a URL: http://www.gtk.org/api/2.6/pango/pango- ... pixel-size
It is possible with pango, but you will have to recode this bit in BaCon (not hard):
Code: Select all
extern GttWidget * curdlg; // of current dialog
void gettextwdht ( char * family , int ptsize , int weight , bool normalstyle ,
char * stringtomeasure ,
int * wdret , int * htret )
{
PangoFontDescription * fd = pango_font_description_new ( );
pango_font_description_set_family (fd, family );
pango_font_description_set_style (fd, normalstyle ? PANGO_STYLE_NORMAL :
PANGO_STYLE_ITALIC );
pango_font_description_set_variant (fd, PANGO_VARIANT_NORMAL);
pango_font_description_set_weight (fd, (PangoWeight)weight );
pango_font_description_set_stretch (fd, PANGO_STRETCH_NORMAL);
pango_font_description_set_size (fd, ptsize * PANGO_SCALE);
PangoContext * context = gtk_widget_get_pango_context ( curdlg ) ;
PangoLayout * layout = pango_layout_new ( context );
pango_layout_set_text ( layout, stringtomeasure, -1 );
pango_layout_set_font_description ( layout, fd );
pango_layout_get_pixel_size (layout, wdret , htret );
g_object_unref ( layout );
}
With kind regards,
vovchik
PS. Here is a URL: http://www.gtk.org/api/2.6/pango/pango- ... pixel-size
EXTRACT$ function
Dear puppians,
Here is a string function (also attached) for BaCon that I just coded and you might also find useful. I haven't tested it extensively, but it seems to work fine. The notes in the code explain what it does.
Here is how to invoke it:
With kind regards,
vovchik
Here is a string function (also attached) for BaCon that I just coded and you might also find useful. I haven't tested it extensively, but it seems to work fine. The notes in the code explain what it does.
Code: Select all
' *****************************************************
' PROGRAM: extract.bac
' PURPOSE: EXTRACT$ function for BaCon (see NOTES)
' AUTHOR: vovchik (Puppy Linux forum)
' DEPENDS: gcc, bacon
' PLATFORM: Puppy Linux (actually, any *nix)
' DATE: 09-12-2011
' LICENSE: GPL3
' *****************************************************
' NOTES
'
' EXTRACT$(STRING src$, STRING match$, NUMBER mode) where
'
' src$ is a string of length > 1 that is to be
' examined and split
'
' match$ is a string of chars for testing the presence
' of ANY of which in src$ and whose earliest position in
' src$ (starting from the left) represents the point for
' substring delimitation.
'
' mode is a flag toggling "extract" and "remain" modes of
' the EXTRACT$ function
'
' If mode = 0, then
'
' EXTRACT$ returns a substring of src$ starting with the first
' character of src$ and up to (but not including) the first
' occurrence of match$. If match$ is not present in src$,
' all of src$ is returned.
'
' If mode = 1, then
'
' EXTRACT$ returns a substring of src$ starting with the first
' character in src$ that matches any string within match$ to the
' end of src$.
'
' In summary, src$ is a string expression from which to
' extract a substring and match$ is a string of chars
' against which matches will be attempted. mode determines
' whether the left part (mode 0) or right part (mode 1)
' of src$ will be returned.
' EXTRACT$ is case-sensitive.
'
' The function is especially useful when parsing a
' string containing arguments to a program.
'
' This implementation combines the functions of typical
' EXTRACT$ and REMAIN$ functions in other languages.
' *****************************************************
' -------------
FUNCTION EXTRACT$(STRING src$, STRING match$, NUMBER mode)
' -------------
LOCAL tst$, ret$, tmp$ TYPE STRING
LOCAL i TYPE NUMBER
' check to see whether there is really something to be split
IF LEN(src$) > 1 THEN
tst$ = ""
tmp$ = ""
' create REGEX compound "OR" type string from match$ string
FOR i = 1 TO LEN(match$)
tst$ = CONCAT$(tst$, MID$(match$, i, 1), "|")
NEXT i
tst$ = LEFT$(tst$, LEN(tst$) - 1)
' if one of the REGEX chars is found in src$,
' then determine the first instance (position) of any of
' the match$ chars within src$
IF REGEX(src$, tst$) THEN
FOR i = 1 TO LEN(match$)
IF INSTR(src$, MID$(match$, i, 1)) THEN
tmp$ = CONCAT$(tmp$, RIGHT$(CONCAT$("0000000000", STR$(INSTR(src$, MID$(match$, i, 1)))), 8), " ")
END IF
NEXT i
tmp$ = CHOP$(tmp$)
SPLIT tmp$ BY " " TO tmp_array$ SIZE tmp_size
SORT tmp_array$
' make substring to return based on mode
SELECT mode
' everything from the left except that which matches
CASE 0
ret$ = LEFT$(src$, VAL(tmp_array$[0]) - 1)
' everything from the right that matches
CASE 1
ret$ = RIGHT$(src$, LEN(src$) - VAL(tmp_array$[0]) + 1)
' placeholder for additional/new modes
DEFAULT
ret$ = src$
END SELECT
ELSE
ret$ = src$
END IF
ELSE
ret$ = src$
END IF
RETURN ret$
END FUNCTION
Code: Select all
source$ = "abcedf"
test$ = "xyz"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bc"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bz"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bz"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "bzt"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "but"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "but"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "bnice -t -g 80x90"
test$ = "-gt"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "IF x$ > 10 THEN"
test$ = ">"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "IF x$ > 10 THEN"
test$ = ">"
PRINT EXTRACT$(source$, test$, 0)
vovchik
- Attachments
-
- extract.bac.tar.gz
- (1.51 KiB) Downloaded 382 times
Hi guys; Anyway to get mouse info ( button, scroll, X, Y ) from Xwin.?
The gtkDialog threads probably have something on this, but they`re five miles long.
BaCon only gets mouse info if the cursor is over a canvas I think, but not over other controls.
Right-click would be nice for BaCon, but Xwin. controls the window, so click action starts there.
The gtkDialog threads probably have something on this, but they`re five miles long.
BaCon only gets mouse info if the cursor is over a canvas I think, but not over other controls.
Right-click would be nice for BaCon, but Xwin. controls the window, so click action starts there.
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Heh heh, I lobbied for BaCon in the Raspberry Pi forum:
http://www.raspberrypi.org/forum?mingle ... pic&t=1474
...well, I have introduced BaCon into their awareness, I probably should back-off now.
http://www.raspberrypi.org/forum?mingle ... pic&t=1474
...well, I have introduced BaCon into their awareness, I probably should back-off now.
[url]https://bkhome.org/news/[/url]