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.
Post Reply
Message
Author
User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#136 Post by BarryK »

2lss wrote:
PjotAwake wrote:Hi 2lss,

Thanks for your contributions. In fact, I have plans for this editor - I would like to add the BaCon converter itself, as a whole, to the program, so it's all embedded in one. We would have a fourth incarnation of BaCon but completely graphical based on GTK.

For the conversion progress, this is something I would rewrite using a Progress Bar.

Furthermore I would add a configuration panel where it is possible to fill in which type of output terminal is being used: xterm, rxvt, Terminal, gnome-terminal. Also in which size it has to appear.

The 'hold' of the terminal, you could embed the execution of the resulting program in a script which simply finishes with a 'read' - this will wait for input from the keyboard.

Tabbing should be added as well.

Syntax completion would be nice but I could not get that to work.

Your additions are a valuable step to these ideas, thanks! So, lots to do, wish there was more time! :-)

Regards
Peter
Glad I could offer some help. I'll keep plugging away at it when I get time.

As far as the terminal "hold" I had a similar thought, but figured the extra script would confuse things. Unless the editor creates/downloads the script when run (similar to the syntax file).....

What do you think about a FIND/HIGHLIGHT option? I found some example C code that might work.
Puppy already has a script for xterm. All Woof-built puppies have /usr/bin/xterm which is a script, unless any particular developer has replaced it.

Wary, Quirky, and many older versions of Puppy have it, in fact if my memory serves me right, even Puppy 4.3.1 has it.

Here is the script:

Code: Select all

#!/bin/sh
#rxvt does not understand the '-hold' option.

if [ "`echo -n ${*} | grep '\-hold '`" != "" ];then
 EXECCOMMAND="`echo -n ${*} | grep -o ' \-e .*' | sed -e 's/ \-e //'`"
 if [ "$EXECCOMMAND" != "" ];then
  echo '#!/bin/sh' > /tmp/xterm_simulate_hold.sh
  echo "$EXECCOMMAND"  >> /tmp/xterm_simulate_hold.sh
  echo 'echo' >> /tmp/xterm_simulate_hold.sh
  echo 'echo -n "FINISHED. PRESS ENTER KEY TO CLOSE THIS WINDOW: "' >> /tmp/xterm_simulate_hold.sh
  echo 'read simuldone' >> /tmp/xterm_simulate_hold.sh
  chmod +x /tmp/xterm_simulate_hold.sh
  exec rxvt -e /tmp/xterm_simulate_hold.sh
 fi
fi

exec rxvt "${@}"
...it tests for '-hold' on the commandline.
[/code]
[url]https://bkhome.org/news/[/url]

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

#137 Post by vovchik »

Dear Barry and Doyle,

Slightly more terse....

Code: Select all

DECLARE prop$ ASSOC STRING

infile$ = "PUPSTATE"
OPEN infile$ FOR READING AS fh
WHILE NOT(ENDFILE(fh)) DO
	READLN txt$ FROM fh
	txt$ = CHOP$(txt$)
	IF INSTR(txt$, "#") EQ 1 THEN CONTINUE
	l$ = LEFT$(txt$,INSTR(txt$, "=") - 1)
	prop$(l$) = CHOP$(MID$(txt$, INSTR(txt$, "=") + 1), "'")
WEND
PRINT prop$("DEV1FS")
PRINT prop$("ZDRV")
PRINT prop$("PUPSAVE")
With kind regards,
vovchik

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

#138 Post by jpeps »

Version of previously posted apps loader using arrays:

http://jpeters.net/apps/MyPrograms.bac.txt

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

picscale v. 0.1a - image converter/rescaler in BaCon

#139 Post by vovchik »

Dear puppians,

Here is revised picture rescaler/converter written in BaCon that makes use of gdk_pixbuf to work its magic. It is pretty small (38k compiled). Since it is a command-line prog, you can use it in bash scripts for the batch processing of image directories etc.

The help screen looks like this:

Code: Select all

picscale image resizer/converter - v.0.1a by vovchik, Puppy Linux Forum, Nov 2010

Input formats supported: pnm, pbm, pgm, ppm, tga, xpm, tiff, pcx, gif,
xbm, wmf, icns, bmp, png, jpg and ico.

Output formats supported: png, jpg, bmp, tiff and ico.

Input parameters: oldfilename newfilename height width quality/compression/depth

Example: picscale old.png new.png 128 128 9

Quality/compression/depth settings:

        bmp (N/A):               0 - 100
        jpeg (quality):          0 - 100
        png (compression):       0 - 9
        tiff (compression type): 1 - 8
        ico (depth):             16, 24 or 32

Check out BaCon at www.basic-converter.org
If you have any suggestions or code mods, please tell me or post them here. The source is in the archive and a working binary in the pet file (installs in /usr/local/bin).

With kind regards,
vovchik
Attachments
picscale.bac.tar.gz
(2.49 KiB) Downloaded 659 times
picscale-0.1a.pet
(13.37 KiB) Downloaded 869 times

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

#140 Post by big_bass »

Hey vovchik

fast and small
what more can you want and
compiled it in bacon 8)


I can see many good apps to follow from you

thanks for posting the app and the source

Joe

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

#141 Post by jpeps »

big_bass wrote:Hey vovchik

fast and small
what more can you want and
compiled it in bacon 8)


I can see many good apps to follow from you

thanks for posting the app and the source

Joe
Great example, although similar cli scaling can be done with about 3 lines using something like exactimage:

example: 'scale old.png new.png 16'

note: econvert also has --quality, which could be the fourth argument

Code: Select all

#!/bin/sh

OldSize=`edentify $1 | cut -d"x" -f1 | cut -d" " -f3`
size=`dc $3 $OldSize / p`  
econvert -i $1 --scale $size -o $2
Last edited by jpeps on Sun 21 Nov 2010, 23:14, edited 1 time in total.

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

Thanks

#142 Post by vovchik »

Dear Joe,

Thanks. I am trying to understand gdk_pixbuf_composite, and once I do satisfactorily, I will change pikona to use only gtk/gdk calls. That means a binary of about 70k without any ImageMagick dependencies that will run on any standard Puppy. Of course, the various background, object and overlay files will still be needed, but the main bulk for the user is now IM and that will be gone. And the transformations will be faster, since they will be made in RAM. And input pics will be able to be in any of the formats that can be read by gtk_pixbuf. Have to get onto this....

With kind regards,
vovchik

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

image conversion

#143 Post by vovchik »

Dear jpeps,

No it can't do that in three lines, unless you install either IM (a good 6 MB binary with libs) or ExactImage (a good 3+ MB binary with libs). Of course econvert and IM's convert can do the job, but I think you may have missed my point above about ugly and huge dependencies. Puppy is supposed to be small and capable, and exploiting gdk_pixbuf (included in the GFK libs in every Puppy by default) is, I think, a good idea.

With kind regards,
vovchik

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

#144 Post by big_bass »

I will change pikona to use only gtk/gdk calls. That means a binary of about 70k without any ImageMagick dependencies

there are a few small apps that do image resize

but there is a little history here that just took place over a long period of time
its hard to follow all the threads so here is a short recap

pikona a great icon making app (compiled in bacon)
uses image magic to do the resize

there is a great small cli c code app MU wrote and compiled

but for some reason the alpha channel had a small error
during the conversion with png that was fixed

then converted from c code to bacon basic
and expanded on adding the IMPORTS

a lot of work went to getting all that to work
so vovchik savor the moment friend

what I like about bacon the most is having
apps that work on all linux distros not
special apps that only work for one special version (like the gtkdialog3 if you plan to share work with the linux
community

Joe

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

#145 Post by vovchik »

Dear Puppians,

I think I have finally understood gdk_pixbuf_composite. Here is a little demo (archive includes src, binary and images). Now I can change Pikona :)

With kind regards,
vovchik
Attachments
new_img.png
(28.91 KiB) Downloaded 1621 times
image2.png
(26.22 KiB) Downloaded 1634 times
image1.png
(18.48 KiB) Downloaded 1609 times
composite-test.tar.gz
(57.78 KiB) Downloaded 601 times

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#146 Post by PjotAwake »

Gents,

Updated the Source Code Editor a bit more.

Tabbing: done.
What do you think about a FIND/HIGHLIGHT option?
Done.

Furthermore did some preparations to integrate with the complete BaCon source. So I am working on it, also looking at contributions from 2lss and mechanic.

For now, code of version 1.4 is here. More to come...

Regards,
Peter

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

#147 Post by vovchik »

Dear PjotAwake,

We are grateful to you for your brains, effort and conscientiousness. I think the IDE will be a VERY useful addition. If we have this, Doyle's glade2bac plus a few utilities that can scan BaCon code and find the (i) undefined function calls to external shared libs (that is, ultimately, compiler errors) and (ii) then do something like an nm -D on the probable libs to automatically produce the imports with proper type defs, life will be a breeze. In a way, one could, for instance, load the entire GTK/GDK stuff, then do a diff on the code to grab only those functions as IMPORTs that are really called, and produce the import list on the basis of matches. I am giving that some thought...

With thanks and kind regards,
vovchik

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

pnotify revisited

#148 Post by vovchik »

Dear puppians,

I revised my notification prog and have attached it here. I eliminated the global HUG dependencies, doing the IMPORTs by hand, and, in so doing, reduced the size of the binary by 50% - now 42k. It is similar to the gnome notify prog, but no icons yet and no command-line argument for duration of the popup, but with complete use of markup. Shall I do the icon and duration bits (we could make it into a 1:1 clone of notify, but without the gnome deps)? It's not a bad way of giving users information about an event that has transpired - i.e. successful inet connection or the completion of some long process such as indexing or backup. Please have a look. The archive contains the source, binary and a bash demo launcher (which shows how to do the markup).

With kind regards,
vovchik
Attachments
pnotify-0.1a.tar.gz
(18.19 KiB) Downloaded 604 times

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#149 Post by seaside »

vovchik,

Thanks for working on this.

I get this -

Code: Select all

./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
Could it be a bash 3 problem?

I also wondered if the BaCon larger font size rendering problem has seen any resolution.

Best Regards,
s

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

#150 Post by vovchik »

Dear Seaside,

Yep, I spoke to Peter about this and our suspicion is that it is bash3 -related. Although Peter recommends bash4 for BaCon (for good reason), I have used GNU bash, version 3.2.48(1)-release (i686-pc-linux-gnu) successfully. Shall I post that binary here? I think Joe has posted a useful bash4 somewhere, and Barry has one posted too. The binary should work in any case -- I hope :)

With kind regards,
vovchik

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

#151 Post by jpeps »

vovchik wrote:Dear Seaside,

Yep, I spoke to Peter about this and our suspicion is that it is bash3 -related. Although Peter recommends bash4 for BaCon (for good reason), I have used GNU bash, version 3.2.48(1)-release (i686-pc-linux-gnu) successfully. Shall I post that binary here? I think Joe has posted a useful bash4 somewhere, and Barry has one posted too. The binary should work in any case -- I hope :)

With kind regards,
vovchik
Here's one I compiled in Lucid

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

pnotify

#152 Post by seaside »

vovchik,

Thanks for your feedback - I did a temp install of bash 4 and got the same....

Code: Select all

 ./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
# bash -version
GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.

Am I the only one getting this error ....... :D :D

Best Regards,
s

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

Re: pnotify

#153 Post by jpeps »

seaside wrote:vovchik,

Thanks for your feedback - I did a temp install of bash 4 and got the same....

Code: Select all

 ./pnotify
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
# bash -version
GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.

Am I the only one getting this error ....... :D :D

Best Regards,
s
Both the enclosed app and freshly compiled app work on this end.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#154 Post by seaside »

jpeps,

I just recompiled the pnotify.bac using bash 4 and it now works!!.

The pnotify exec included in Vovchik's package did not run in bash 3 or 4. That is still a bit of a puzzle??

Oh, well.... :D

Cheers,
s

EDIT: I reverted back to bash 3 and it runs there also
Last edited by seaside on Mon 29 Nov 2010, 23:54, edited 1 time in total.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#155 Post by BarryK »

seaside wrote:I also wondered if the BaCon larger font size rendering problem has seen any resolution.
In my Proxy Server Setup application now used in Woof, see /usr/local/simple_network_setup/proxy-setup.bac in recent Wary/Quirky/Luci builds, I attempted to adjust font size so that the text will always fit the window.

I have this at the beginning of my program (using HUG):

Code: Select all

REM try to set font size to fit window... ex: xdpy=107 xftdpi=78
xdpi=VAL(EXEC$("xdpyinfo | grep -o 'resolution: .*' | tr -s ' ' | cut -f 2 -d ' ' | cut -f 1 -d 'x'"))
xftdpi=VAL(EXEC$("grep '^Xft.dpi:.*' /root/.Xresources | tr -s ' ' | cut -f 2 -d ' '"))
REM my weird formula...
fontsize=12.0*(78.0/xftdpi)*(107.0/xdpi)
fontsize_mono=fontsize
fontsize$=STR$(fontsize)
fontsize_mono$=STR$(fontsize_mono)
font_sans$=CONCAT$("DejaVu Sans ",fontsize$)
font_mono$=CONCAT$("Monospace ",fontsize_mono$)
Then in the program I use FONT function on all text, for example:

Code: Select all

ATTACH(mainwin, label_http, 10, 100)
FONT(label_http,font_sans$)
I can't guarantee the accuracy of my formula, but it seemed ok in limited testing.

I don't know if this idea of keeping the text always the same size regardless, would appeal to everybody.
[url]https://bkhome.org/news/[/url]

Post Reply