|
Post by alexfish on Apr 30, 2023 21:35:10 GMT 1
Bug fix mem leak gtk image in post above docs.gtk.org/gtk3/method.Image.clear.htmlon gtk_image_clear(image) gtk_image_set_from_pixbuf (image,pixbuf) source code on gtk_image_set_from_pixbuf (image,pixbuf) indicates the function gtk_image_clear(image) is done there.. indications = NOT can suggest in hug gtk2 and using image import the function & apply here I am looking at ' TRY pixbuf gdk_pixbuf_get_from_surface ' gtk_image_new_from_surface () ' gtk_image_set_from_surface () 'GtkImage *image,surface' there was gtk update a few weeks ago and all looked fine prior to BR Alex
|
|
|
Post by alexfish on May 1, 2023 7:43:01 GMT 1
Hi All Improved version call myweb
fixed links(used from my original html parser) adds last call to LIST, external links add to EDIT in edit will record links + show any errors if any thing of interest can copy and paste in the webview or copy & paste to where ever. in my case foogle dir / so can search the bits more on that one later but think most members will be able to do that. a bit like book mark
now in process of modding the original index.html + download images to assets dir hence can cache
Have Fun + BR Alex
INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") '======================================================= HOME$= GETENVIRON$("HOME") '======================================================= PRINT HUG_VERSION$ GLOBAL BASE$ '====================================================== FUNCTION WEBVIEW(hug_xsize,hug_ysize)
LOCAL view, scrolled,image,ebox LOCAL pixbuf image = gtk_image_new() ebox = gtk_event_box_new() scrolled = gtk_scrolled_window_new(0, 0) gtk_scrolled_window_set_policy(scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC) gtk_scrolled_window_set_shadow_type(scrolled, GTK_SHADOW_ETCHED_OUT) gtk_container_add(scrolled, image)
IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(scrolled) ' - width if put in another scroller hug_widget_xsize(STR$(scrolled)) = hug_xsize hug_widget_ysize(STR$(scrolled)) = hug_ysize
hug_widget_signal(STR$(ebox)) = 4 hug_widget_s_widget(STR$(scrolled))=ebox hug_widget_type$(STR$(ebox)) = "image"
hug_widget_font(STR$(scrolled)) = image hug_widget_focus(STR$(ebox)) = image '======================================================
RETURN scrolled
END FUNCTION '====================================================== SUB LINKS(long hugwidget,STRING url$,STRING links$) LOCAL dim LOCAL txt$ links$ = REPLACE$(links$,"'",CHR$(34)) 'TEXT(hugwidget,"")
TEXT(hugwidget,url$)
SPLIT links$ BY NL$ TO arg$ SIZE dim FOR t = 0 TO dim -1 txt$= arg$[t] txt$= MID$(txt$,INSTR(txt$,"=")+1) txt$= MID$(txt$,1,INSTR(txt$,"=")-1) txt$= MID$(txt$,INSTR(txt$,CHR$(34))+1) txt$= MID$(txt$,1,INSTR(txt$,CHR$(34))-1) txt$= MID$(txt$,1,INSTR(txt$,"</")-1)
'txt$= MID$(txt$,INSTR(txt$,CHR$(34))-1)
IF LEN(txt$) AND NOT(INSTR(txt$,"<")) THEN IF BASE$ = url$ THEN TEXT(hugwidget,txt$) ELSE TEXT(ed,txt$) TEXT(ed,NL$) END IF END IF NEXT END SUB
'====================================================== FUNCTION ParseUrls$(STRING html$) LOCAL txt$,res$,rte$ LOCAL ptr txt$ = LOAD$(html$) txt$= REPLACE$(txt$,NL$,"") txt$= REPLACE$(txt$,"/a","") txt$= REPLACE$(txt$,"/p","") txt$= REPLACE$(txt$,"<a","<") txt$= REPLACE$(txt$,"<li","<") txt$= REPLACE$(txt$,"<div","<") txt$= REPLACE$(txt$,"<p","<") txt$= REPLACE$(txt$,"<h2","<") txt$= REPLACE$(txt$,"<h1","<") txt$= REPLACE$(txt$,"<h3","<") txt$= REPLACE$(txt$,"<h4","<") txt$= REPLACE$(txt$,"<h5","<") txt$= REPLACE$(txt$,"<h6","<")
txt$= REPLACE$(txt$,"</h2","<") txt$= REPLACE$(txt$,"</h1","<") txt$= REPLACE$(txt$,"</h3","<") txt$= REPLACE$(txt$,"</h4","<") txt$= REPLACE$(txt$,"</h5","<") txt$= REPLACE$(txt$,"</h6","<") txt$= REPLACE$(txt$,"/span","") txt$= REPLACE$(txt$,"/sup","") txt$= REPLACE$(txt$,"/script","") txt$= REPLACE$(txt$,"/body","") txt$= REPLACE$(txt$,"/html","") txt$= REPLACE$(txt$,"'",CHR$(34)) txt$= REPLACE$(txt$,"{",NL$) txt$= REPLACE$(txt$,"}",NL$) txt$= REPLACE$(txt$,"<",NL$) txt$= REPLACE$(txt$,">",NL$) txt$= REPLACE$(txt$,");","") SPLIT txt$ BY NL$ TO arg$ SIZE dim txt$ = "" FOR t = 0 TO dim -1 res$ = arg$[t] IF INSTR(res$,"href=") THEN res$ = MID$(res$,INSTR(res$,"href=")) IF LEN(res$) >10 THEN txt$ = txt$ & res$ txt$ = txt$ & NL$ END IF END IF IF INSTR(res$,"src=") THEN res$ = MID$(res$,INSTR(res$,"src=")) IF LEN(res$) >10 THEN txt$ = txt$ & res$ txt$ = txt$ & NL$ END IF END IF
NEXT RETURN txt$ END FUNCTION '====================================================== SUB Load_Url(long hug_widget,STRING url$)
LOCAL layer, buffer,image,ebox,buf,res LOCAL new$,cmd$
image = hug_widget_font(STR$(hug_widget)) PRINT "IM is ", image
IF INSTR(url$,"http") AND INSTR(url$,"://") THEN PRINT "url :", url$ IF (INSTR(url$,".png") OR INSTR(url$,".jpg")) THEN IF (INSTR(url$,".png")) THEN cmd$ = "curl " & url$ & CHR$(32) & "-o " & HOME$ & "/test12.png" SYSTEM (cmd$) IF FILEEXISTS(HOME$ & "/test12.png") THEN
pixbuf = gdk_pixbuf_new_from_file(HOME$ & "/test12.png", 0) PRINT pixbuf res = gdk_pixbuf_get_width(pixbuf) PRINT res gtk_image_clear(image) gtk_image_set_from_pixbuf (image,pixbuf) g_object_unref(pixbuf) ' END IF
END IF
IF (INSTR(url$,".jpg")) THEN cmd$ = "curl " & url$ & CHR$(32) & "-o " & HOME$ & "/test12.jpg" SYSTEM (cmd$) IF FILEEXISTS(HOME$ & "/test12.jpg") THEN
pixbuf = gdk_pixbuf_new_from_file(HOME$ & "/test12.jpg", 0) PRINT pixbuf res = gdk_pixbuf_get_width(pixbuf) PRINT res gtk_image_clear(image) gtk_image_set_from_pixbuf (image,pixbuf) g_object_unref(pixbuf) ' END IF
END IF
ELSE cmd$ = "weasyprint -p -r 90 -q -f png " & url$ & CHR$(32) & HOME$ & "/test8.png" SYSTEM (cmd$) IF FILEEXISTS(HOME$ & "/test8.png") THEN
pixbuf = gdk_pixbuf_new_from_file(HOME$ & "/test8.png", 0) PRINT pixbuf res = gdk_pixbuf_get_width(pixbuf) PRINT res gtk_image_clear(image) gtk_image_set_from_pixbuf (image,pixbuf) g_object_unref(pixbuf) ' END IF END IF END IF PRINT hug_widget_xsize(STR$(hug_widget)) END SUB '====================================================== SUB LoadHtml(long hug_widget,STRING url$)
LOCAL layer, buffer,image,ebox,buf,res LOCAL new$,cmd$
image = hug_widget_font(STR$(hug_widget))
cmd$ = "weasyprint -p -r 90 -q -f png " & url$ & CHR$(32) & HOME$ & "/test8.png" SYSTEM (cmd$) IF FILEEXISTS(HOME$ & "/test8.png") THEN
pixbuf = gdk_pixbuf_new_from_file(HOME$ & "/test8.png", 0) PRINT pixbuf res = gdk_pixbuf_get_width(pixbuf) PRINT res gtk_image_clear(image) gtk_image_set_from_pixbuf (image,pixbuf) g_object_unref(pixbuf) ' END IF END SUB '====================================================== DECLARE TOG
SUB togList()
TOG=NOT(TOG) IF (TOG) THEN SHOW(list) ELSE HIDE(list) END IF SYNC END SUB '====================================================== SUB GetUrl() PRINT IF TOG THEN togList END IF
LOCAL txt$,cmdf2$,urlsd$ txt$ = GRAB$(list) IF NOT(INSTR(txt$,"http")) THEN txt$ = BASE$ & txt$ END IF TEXT(ent,txt$) cmdf2$ = "curl " & txt$ & CHR$(32) & "-o " & HOME$ & "/index.html" SYSTEM (cmdf2$) urlsd$ = ParseUrls$(HOME$ & "/index.html") LINKS(list,txt$,urlsd$)
Load_Url(web,txt$) END SUB
'================================================================================= SUB SetUrl()
IF TOG THEN togList END IF LOCAL txt$,cmd$,urls$,cmdf2$,urlsd$ txt$ = GRAB$(ent)
IF ((INSTR(txt$,"http")) AND (INSTR(txt$,"://") ) ) THEN cmdf2$ = "curl " & txt$ & CHR$(32) & "-o " & HOME$ & "/index.html" SYSTEM (cmdf2$) urlsd$ = ParseUrls$(HOME$ & "/index.html") LINKS(list,txt$,urlsd$)
Load_Url(web,txt$) END IF END SUB
'================================================================================= win = WINDOW("Web-View", 806, 606)
'NOTEBOOK returns notebook no pages ===== NoteBook =NOTEBOOK("WebView ",800,600) ATTACH(win,NoteBook,3,3)
'add first page page1 = PAGE(NoteBook,"Web View")
ent = ENTRY("http://www.basic-converter.org/",400,-1) CALLBACK(ent,SetUrl)
PAGESET(page1,ent,3,3) but = BUTTON("L",-1,-1) PAGESET(page1,but,406,3) CALLBACK(but,togList) web = WEBVIEW(780,520) PAGESET(page1,web,3,40) list = LIST(323,200) CALLBACK(list,GetUrl) cmdf$ = "curl " & "http://www.basic-converter.org/" & CHR$(32) & "-o " & HOME$ & "/index.html" SYSTEM (cmdf$) urls$ = ParseUrls$(HOME$ & "/index.html") BASE$ = "http://www.basic-converter.org/" LINKS(list,"http://www.basic-converter.org/",urls$)
PAGESET(page1,list,457,3)
page2 = PAGE(NoteBook,"LINKS") ed = EDIT(780,530) PAGESET(page2,ed,3,3) page$ = LOAD$(HOME$ & "/index.html")
'Load_Url(web,"http://www.basic-converter.org/") LoadHtml(web,"index.html") SETPAGE(NoteBook, 0) HIDE(list) '============================== DISPLAY '==============================
|
|
|
Post by alexfish on May 1, 2023 7:58:21 GMT 1
Q: How can I foogle A:Add layer to web view Add picky of your home page Add ENTRY , say some where Centered press enter, if success HIDE HOME (layer) Viola Hint /* SEARCH SEARCH(handle, string [,flag])
Type: function
Searches for <string> in file opened with <handle>. The search returns the byte offset in the file where the first occurrence of <string> is located. Use SEEK to effectively put the filepointer at this position. If the string data is not found, then the value '-1' is returned.
Optionally, a third argument can be used to determine where to start the search and in which direction the search should take place. The following values are accepted:
0: start at the beginning of the file, search forward (default) 1: start at the current position of the filepointer, search forward 2: start at the current position of the filepointer, search backward 3: start at the end of the file, search backward.
Note that when searching backwards, the actual search begins at the start position minus the length of the searched string
A$ = "bacon" OPEN "data.txt" FOR READING AS myfile WHILE NOT(ENDFILE(myfile)) DO READLN txt$ FROM myfile IF NOT(ENDFILE(myfile)) THEN IF INSTR(txt$,A$) THEN PRINT txt$ END IF ENDIF WEND CLOSE FILE myfile */ And so TO /* SEARCH SEARCH(handle, string [,flag])
Type: function
Searches for <string> in file opened with <handle>. The search returns the byte offset in the file where the first occurrence of <string> is located. Use SEEK to effectively put the filepointer at this position. If the string data is not found, then the value '-1' is returned.
Optionally, a third argument can be used to determine where to start the search and in which direction the search should take place. The following values are accepted:
0: start at the beginning of the file, search forward (default) 1: start at the current position of the filepointer, search forward 2: start at the current position of the filepointer, search backward 3: start at the end of the file, search backward.
Note that when searching backwards, the actual search begins at the start position minus the length of the searched string
*/
/* OPEN "." FOR DIRECTORY AS mydir REPEAT GETFILE myfile$ FROM mydir PRINT "File found: ", myfile$ UNTIL ISFALSE(LEN(myfile$)) CLOSE DIRECTORY mydir e */ INCLUDE hug.bac A$ = "BaCon" LOCAL res$ HOME$= GETENVIRON$("HOME") OPEN HOME$ & "/bacon2.txt" FOR READING AS myfile x = SEARCH(myfile,A$ ,0) IF x THEN WHILE NOT(ENDFILE(myfile)) DO READLN txt$ FROM myfile IF NOT(ENDFILE(myfile)) THEN IF INSTR(txt$,A$) THEN res$=res$ & txt$ & NL$ END IF ENDIF WEND END IF CLOSE FILE myfile
win = WINDOW("Foogle It", 800, 500) ed=EDIT(800, 500) ATTACH(win,ed, 0, 0) TEXT(ed,res$)
DISPLAY If pages are correct in format then can break at first line IF INSTR(txt$,A$) THEN res$=res$ & txt$ & NL$ BREAK END IF the single output looks like [BaCon](http://www.basic-converter.org/) is a free BASIC to C translator for Have Fun + BR Alex Picky Attachments:
|
|
|
Post by alexfish on May 1, 2023 16:36:26 GMT 1
And So To
The Home brew Parser
I did a thread HTTPIE in there is the parser , well not quite Can take the text straight out of the bag. Same with links
html entities are converted to ooooh
this is a sample of BaCon
<!-- ABOUT WRAP --> <div id="about"> <div class="container"> <div class="row" style="margin-top: 50px"> <h2> "About" </h2> <p> <a href="http://www.basic-converter.org/"> "BaCon" </a> " is a free BASIC to C translator for Unix-based systems, which runs on most Unix/Linux/BSD platforms, including MacOSX. It intends to be a programming aid in creating tools which can be compiled on different platforms (32bit and 64bit), while trying to revive the days of the good old " <a href="http://en.wikipedia.org/wiki/BASIC_programming_language"> "BASIC" </a> ". " </p> <p> "BaCon can be described as a translator, a converter, a source-to-source compiler, a transcompiler or a transpiler. It also can be described as a very elaborate preprocessor to C. BaCon is implemented in generic shell script and in itself. Therefore, to start using Bacon, the target system must have either
so can extract what ever + can still be used by a browser and or the likes of weasyprint or do our own rendering with hug imager + add the callbacks to the links More later HUG WEBKIT BR Alex
|
|
|
Post by alexfish on May 1, 2023 16:57:16 GMT 1
To Start Need OPTION QUOTED FALSE
USEH #include "ents.c" END USEH
DECLARE MY_ENTS$[256][2] TYPE STRING DECLARE my_ent_start$ = "" TYPE STRING DECLARE my_ent_end$ =";" TYPE STRING
LOCAL dimention TYPE int LOCAL ck$ TYPE STRING LOCAL ap$ = argv[0]
LOCAL HTML$
FOR t = 0 TO 255 MY_ENTS$[t][0]= my_ent_start$ & CHR$(t) & my_ent_end$ MY_ENTS$[t][1]= CHR$(t) NEXT
IF argc = 2 THEN file$ = argv[1] PRINT file$ , "\n\n" ELSE PRINT "usage" PRINT ap$ , " <file.html>" END END IF '" "
IF ( FILEEXISTS( file$)) THEN
HTML$= LOAD$(file$) IF INSTR(HTML$,"<") THEN HTML$ = REPLACE$(HTML$,">", ">" NL$ & CHR$(34) ) END IF
IF INSTR(HTML$,">") THEN HTML$ = REPLACE$(HTML$,"<", CHR$(34) & NL$ & "<") END IF
IF INSTR(HTML$,"{") THEN HTML$ = REPLACE$(HTML$,"{","{" & NL$) END IF
SPLIT HTML$ BY NL$ TO my_array$ SIZE dimention HTML$ = "" FOR t = 0 TO dimention -1 ck$ = my_array$[t] ck$= CHOP$(ck$) HTML$ = HTML$ & ck$ & NL$ NEXT
SPLIT HTML$ BY NL$ TO my_array2$ SIZE dimention HTML$="" FOR t = 0 TO dimention -1 ck$ = my_array2$[t] ck$= CHOP$(ck$) HTML$ = HTML$ & ck$ & NL$ NEXT HTML$ = REPLACE$(HTML$,CHR$(34) & NL$ & CHR$(34) & NL$,"") HTML$ = REPLACE$(HTML$,CHR$(34) & CHR$(34),"") FOR t = 0 TO 252 p$ = NAMED_ENTITIES[t][0] pr$ = NAMED_ENTITIES[t][1] IF INSTR(HTML$,p$) THEN HTML$= REPLACE$(HTML$,p$,pr$) END IF NEXT
FOR t = 0 TO 255 p$ = MY_ENTS$[t][0] pr$ = MY_ENTS$[t][1] IF INSTR(HTML$,p$) THEN HTML$= REPLACE$(HTML$,p$,pr$) END IF NEXT PRINT HTML$ ' can imp rest of parser here ELSE
PRINT "file not exist " END IF and the archive Attachments:ents.c.bz2 (1.39 KB)
|
|
|
Post by alexfish on May 1, 2023 18:17:35 GMT 1
And with this
can get this site & more
PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` HOME$= GETENVIRON$("HOME") PRAGMA INCLUDE <libsoup/soup.h>
DECLARE session TYPE static SoupSession * DECLARE loop TYPE static GMainLoop * DECLARE debug, head, quiet TYPE static gboolean DECLARE output_file_path = NULL TYPE static const gchar *
DECLARE opts TYPE GOptionContext * DECLARE url TYPE const char * DECLARE *proxy_uri, *parsed TYPE SoupURI DECLARE error = NULL TYPE GError * DECLARE logger = NULL TYPE SoupLogger * DECLARE help TYPE char *
PROTO gprint,soup_session_send_message,soup_message_get_uri,soup_message_get_https_status PROTO g_free,soup_uri_free,g_object_unref
SUB HTTPIE(STRING url$ , STRING saveto$ ) LOCAL parsed$ TYPE STRING LOCAL name TYPE STRING LOCAL msg TYPE SoupMessage * LOCAL header TYPE STRING LOCAL GTlsCertificateFlags flags LOCAL responce$ TYPE STRING msg = soup_message_new ( "GET", url$) soup_session_send_message (session, msg) name = soup_message_get_uri (msg)->path
IF (msg->status_code == SOUP_STATUS_SSL_FAILED) THEN
LOCAL flags TYPE GTlsCertificateFlags
IF (soup_message_get_https_status (msg, NULL, &flags)) THEN PRINT name, msg->status_code, msg->reason_phrase, flags FORMAT "%s: %d %s (0x%x)\n" ELSE PRINT name, msg->status_code, msg->reason_phrase FORMAT "%s: %d %s (no handshake status)\n" END IF
END IF
IF ( SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) THEN PRINT name, msg->status_code, msg->reason_phrase FORMAT "%s: %d %s\n" END IF
IF (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) THEN header = soup_message_headers_get_one (msg->response_headers,"Location")
IF (header) THEN LOCAL uri TYPE SoupURI * LOCAL uri_string TYPE STRING uri = soup_uri_new_with_base (soup_message_get_uri (msg), header) uri_string = soup_uri_to_string (uri, FALSE) HTTPIE (uri_string,saveto$) g_free (uri_string) soup_uri_free (uri) ELSE PRINT "redirect fail" END IF
END IF '===SUCCESS ================================================ IF (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) THEN responce$ = msg->response_body->data 'PRINT responce$ SAVE responce$ TO saveto$ END IF
END SUB '================================================================= session = g_object_new (SOUP_TYPE_SESSION, \ SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER, \ SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_COOKIE_JAR, \ SOUP_SESSION_USER_AGENT, "get ", \ SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, TRUE, \ NULL) 'https://www.google.com/search?q= bacon+linux 'HTTPIE ("http://www.basic-converter.org","index.html") 'HTTPIE ("https://www.youtube.com/results?search_query=pink+floyd","index.html") 'https://basic-converter.proboards.com/ HTTPIE ("https://basic-converter.proboards.com/",HOME$ & "/proboards.html")
g_object_unref (session)
Now there are java script to negotiate, soup can do it
and the parser posted above makes the code readable + in previous example easy to extract the text
Example : part of
<title> "Home | The BAsic CONverter Forum" </title> <script async src="//c.amazon-adsystem.com/aax2/apstag.js">
</script> <script> "!function(a9,a,p,s,t,A,g){ if(a[a9])return;function q(c,r){ a[a9]._Q.push([c,r])}a[a9]={ unLoaded:1,init:function(){ q("i",arguments)},fetchBids:function(){ q("f",arguments)},setDisplayBids:function(){ },targetingKeys:function(){ return[]},dpa:function(){ q("di",arguments)},rpa:function(){ q("ri",arguments)},upa:function(){ q("ui",arguments)},_Q:[]};}("apstag",window);" </script> <script async src="https://config.htplayground.com/load-vs-cmp.js">
</script> <script async src="https://config.htplayground.com/config/proboards.com">
</script> <script async src="https://config.htplayground.com/libs">
</script> <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js">
</script> <script> " window.deployads = window.deployads || []; window.googletag = window.googletag || { cmd: []}; googletag.cmd.push(function() {
//Size Mapping var topMapping = googletag.sizeMapping() .addSize([970, 200], [[728, 90], [970, 90], [468, 60], [480, 75], [320, 50], [300, 50], [234, 60]]) .addSize([728, 200], [[728, 90], [468, 60], [480, 75], [320, 50], [300, 50], [234, 60]]) .addSize([0, 0], [[300, 250], [336, 280], [320, 50], [300, 50], [250, 250], [234, 60], [200, 200], [180, 150]]) .build(); var bottomMapping = googletag.sizeMapping() .addSize([970, 200], [[970, 90], [728, 90], [300, 250], [336, 280], [320, 50], [300, 50], [250, 250], [234, 60], [200, 200], [180, 150], [125, 125]]) .addSize([728, 200], [[728, 90], [300, 250], [336, 280], [320, 50], [300, 50], [250, 250], [234, 60], [200, 200], [180, 150], [125, 125]]) .addSize([0, 0], [[300, 250], [336, 280], [320, 50], [300, 50], [250, 250], [234, 60], [200, 200], [180, 150], [125, 125]]) .build(); var adhesionMapping = googletag.sizeMapping() .addSize([970, 200], [[728, 90], [970, 90], [468, 60], [480, 75], [320, 50], [300, 50], [234, 60]]) .addSize([728, 200], [[728, 90], [468, 60], [480, 75], [320, 50], [300, 50], [234, 60]]) .addSize([0, 0], [[320, 50], [300, 50], [234, 60]]) .build(); //Size Mapping end
googletag.defineSlot('/1030735/ProBoards_com_Top', [[250, 250], [336, 280], [300, 250], [728, 90], [320, 50], [468, 60], [970, 90], [234, 60], [180, 150], [200, 200], [480, 75], [300, 50]], 'ProBoards_com_Top').defineSizeMapping(topMapping).addService(googletag.pubads()); googletag.defineSlot('/1030735/ProBoards_com_Bottom', [[125, 125], [250, 250], [320, 50], [970, 90], [200, 200], [300, 250], [728, 90], [234, 60], [336, 280], [180, 150], [300, 50]], 'ProBoards_com_Bottom').defineSizeMapping(bottomMapping).addService(googletag.pubads()); googletag.defineSlot('/1030735/ProBoards_com_Adhesion', [[728, 90], [970, 90], [468, 60], [480, 75], [320, 50], [300, 50], [234, 60]], 'ProBoards_com_Adhesion').defineSizeMapping(adhesionMapping).addService(googletag.pubads());
googletag.pubads().enableSingleRequest(); googletag.pubads().setTargeting("sitename", "Proboards.com"); googletag.pubads().setTargeting("proboardsforumid", "3081746"); googletag.pubads().setTargeting("forum_id", "0"); googletag.pubads().setTargeting("vertical", ); googletag.pubads().setCentering(true); deployads.push(function () { deployads.gpt.enableServices() });
if("0" === "0") {
function onDomLoadAdhesion() {
let footeradcontainer = document.createElement('div'); footeradcontainer.classList.add('desktop-adhesion-ad__footer-ad-container');
BR Alex
|
|
|
Post by alexfish on May 1, 2023 20:13:03 GMT 1
Tip of the Day How to parse a Alex parser bit for example <p> "BaCon can be described as a translator, a converter, a source-to-source compiler, a transcompiler or a transpiler. It also can be described as a very elaborate preprocessor to C. BaCon is implemented in generic shell script and in itself. Therefore, to start using Bacon, the target system must have either " <a href="http://www.kornshell.com"> "Korn Shell" in general term text will have (") LEFT(*$,1) "BaCon can be described as a translator, OK NOW step back to entity, paragraph <p> and the text ends in (") Next "Korn Shell"
step back <a href=" What about <br> I am a Bad BOY IF inside text then do it check for end entitity in general terms spacing will look like <p> " The shell script implementation can convert and compile the BaCon version of BaCon. This will deliver the binary version of BaCon which has an extremely high conversion performance. On newer systems, the average conversion rate usually lies above 10.000 lines per second. " </p> depends if following stricked , as in rules are I do not follow the rules What Browser does & what Author does Both are guilty No, That's 3 anyway they Bladdered thing altogether with That thing called script Have Fun + BR Alex Added Google output the good old BASIC.
BaCon can be described as a translator, a converter, a source-to-source compiler, a transcompiler or a transpiler. It also can be described as a ME "BASIC" </a> ". " </p> <p> "BaCon can be described as a translator, Well. put the . where it should be, remove the bits another " Now only one program has to be downloaded to perform Basic-to-C conversion, so no hazzle to download different kinds of binaries for all the different Unix versions with their particular binary formats and dependencies." </li> </ol> <br> " If you think this is impossible or strange or " Does it Always work there again the parser complete = only about 100 lines of code
|
|
|
Post by alexfish on May 1, 2023 21:30:39 GMT 1
java script take away the curly bits and ; = a 'very very heavy weight and very drunk BASIC INTERPRETER So have something simple, from gtkhtml, test bits <html> <h1>A lot of pictures</h1> <p> <hr> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> <p> <a href=www.gnome.org><img border=0 src="test.jpg"></a> </p> </html> save as .html put in same folder with the archive Yes Un Zip it click on the on html file in BaCon HUG: Make a grid pack grid vertical with IMAGE's Viola where if <p> = text pack grid with edit's, but here make own edit without the scrolled window Attachments:test.jpg.bz2 (9.92 KB)
|
|
|
Post by alexfish on May 1, 2023 22:54:01 GMT 1
a bit of help
INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") '======================================================= HOME$= GETENVIRON$("HOME") gtk$ = HUGLIB$("gtk") IMPORT gtk_text_view_set_cursor_visible (long,int) FROM gtk$ TYPE void
'======================================================= PRINT HUG_VERSION$
FUNCTION PARAGRAPH (int hug_xsize, int hug_ysize) LOCAL buffer, view
buffer = gtk_text_buffer_new(0) view = gtk_text_view_new_with_buffer(buffer) gtk_text_view_set_editable(view, 0) gtk_text_view_set_wrap_mode(view, 3) gtk_text_view_set_cursor_visible(view,FALSE) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(view)
hug_widget_xsize(STR$(view)) = hug_xsize hug_widget_ysize(STR$(view)) = hug_ysize hug_widget_signal(STR$(view)) = 5 hug_widget_s_widget(STR$(view)) = buffer
hug_widget_type$(STR$(view)) = "edit" hug_widget_font(STR$(view)) = view hug_widget_focus(STR$(view)) = view WIDGET = view
RETURN view
END FUNCTION
win= WINDOW("para",806,606) ed= PARAGRAPH(800,100) ATTACH(win,ed,3,3) TEXT(ed,"HELLO WORLD" & NL$) DISPLAY
or can just attach the paragraphs where ever in fact can attach images see previous posts of gtk_image_new and set pixbuf use
buf2 = gdk_pixbuf_scale_simple(buf,hug_xsize,hug_ysize,GDK_INTERP_HYPER) and set the image
can copy text only '======================================= bonny bits & hyper links see cairo bits & event boxes
BR Alex
|
|
|
Post by alexfish on May 1, 2023 23:59:05 GMT 1
And So TO first bit INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") '======================================================= HOME$= GETENVIRON$("HOME") gtk$ = HUGLIB$("gtk") IMPORT gtk_text_view_set_cursor_visible (long,int) FROM gtk$ TYPE void IMPORT gtk_text_buffer_insert_pixbuf (long,long,long) FROM gtk$ TYPE void
'======================================================= PRINT HUG_VERSION$
FUNCTION PARAGRAPH (int hug_xsize, int hug_ysize) LOCAL buffer, view
buffer = gtk_text_buffer_new(0) view = gtk_text_view_new_with_buffer(buffer) gtk_text_view_set_editable(view, 0) gtk_text_view_set_wrap_mode(view, 3) gtk_text_view_set_cursor_visible(view,FALSE) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(view)
hug_widget_xsize(STR$(view)) = hug_xsize hug_widget_ysize(STR$(view)) = hug_ysize hug_widget_signal(STR$(view)) = 5 hug_widget_s_widget(STR$(view)) = buffer
hug_widget_type$(STR$(view)) = "edit" hug_widget_font(STR$(view)) = view hug_widget_focus(STR$(view)) = view WIDGET = view
RETURN view
END FUNCTION '======================================================= SUB INSERTIMAGE(long hug_widget,STRING hug_text$) LOCAL iter,buf,pixbuf buf = hug_widget_s_widget(STR$(hug_widget)) pixbuf = gdk_pixbuf_new_from_file(hug_text$, 0) iter = MEMORY(HUG_DEFAULT_WIDGET_SIZE) gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iter) gtk_text_buffer_insert_pixbuf(buf,iter,pixbuf) g_object_unref(pixbuf) FREE iter END SUB '=======================================================
win= WINDOW("para",806,606) ed= PARAGRAPH(800,100) ATTACH(win,ed,3,3) TEXT(ed,"HELLO WORLD" & NL$) TEXT(ed,"Have Fun playing with HUG") INSERTIMAGE(ed,HOME$ & "/test12.png") '======================================================= DISPLAY '======================================================= Attachments:
|
|
|
Post by alexfish on May 2, 2023 2:20:32 GMT 1
And A bit Further INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") OPTION UTF8 TRUE '======================================================= HOME$= GETENVIRON$("HOME") gtk$ = HUGLIB$("gtk") IMPORT gtk_text_view_set_cursor_visible (long,int) FROM gtk$ TYPE void IMPORT gtk_text_buffer_insert_pixbuf (long,long,long) FROM gtk$ TYPE void IMPORT "gtk_text_buffer_create_tag(long,char*,char*,...)" FROM gtk$ TYPE long IMPORT "gtk_text_buffer_insert_with_tags_by_name(long,long,char*,...)" FROM gtk$ TYPE void IMPORT "gtk_text_buffer_apply_tag(long,long,long,long)" FROM gtk$ TYPE void IMPORT "gtk_text_buffer_get_iter_at_offset(long,long,int)" FROM gtk$ TYPE void '======================================================= PRINT HUG_VERSION$ '======================================================= FUNCTION PARAGRAPH (int hug_xsize, int hug_ysize) LOCAL buffer, view, here
buffer = gtk_text_buffer_new(0) view = gtk_text_view_new_with_buffer(buffer) gtk_text_view_set_editable(view, 0) gtk_text_view_set_wrap_mode(view, 3) gtk_text_view_set_cursor_visible(view,FALSE) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(view)
hug_widget_xsize(STR$(view)) = hug_xsize hug_widget_ysize(STR$(view)) = hug_ysize hug_widget_signal(STR$(view)) = 5 hug_widget_s_widget(STR$(view)) = buffer
hug_widget_type$(STR$(view)) = "edit" hug_widget_font(STR$(view)) = view hug_widget_focus(STR$(view)) = view WIDGET = view
RETURN view
END FUNCTION '======================================================= SUB BLUETAG(long hug_widget,int start,int end) A$ = GRAB$(ed) LOCAL iters,itere,buf,pixbuf buf = hug_widget_s_widget(STR$(hug_widget)) iters = MEMORY(HUG_DEFAULT_WIDGET_SIZE) itere = MEMORY(HUG_DEFAULT_WIDGET_SIZE) gtk_text_buffer_get_iter_at_offset(buf,iters,LEN(A$)-start) gtk_text_buffer_get_iter_at_offset(buf,itere,LEN(A$)-end) 'gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iters) tag = gtk_text_buffer_create_tag(buf,"blue_foreground", "foreground", "blue", NULL) 'gtk_text_buffer_insert_with_tags_by_name(buf, iters,"This", tag, NULL) gtk_text_buffer_apply_tag(buf,tag,iters,itere) FREE iters FREE itere END SUB '=======================================================
SUB INSERTIMAGE(long hug_widget,STRING hug_text$) LOCAL iter,buf,pixbuf buf = hug_widget_s_widget(STR$(hug_widget)) pixbuf = gdk_pixbuf_new_from_file(hug_text$, 0) iter = MEMORY(HUG_DEFAULT_WIDGET_SIZE) gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iter) gtk_text_buffer_insert_pixbuf(buf,iter,pixbuf) g_object_unref(pixbuf) FREE iter END SUB '=======================================================
win= WINDOW("para",806,606) ed= PARAGRAPH(800,100) ATTACH(win,ed,3,3) TEXT(ed,"HELLO WORLD" & NL$) TEXT(ed,"Have Fun playing with HUG") INSERTIMAGE(ed,HOME$ & "/test12.png") TEXT(ed,NL$) TEXT(ed,"See you at Basic Converter Forum HERE" & NL$) BLUETAG(ed ,4,0)
'=======================================================
DISPLAY '======================================================= opted for apply tag , problem with other + can tag by find key word , using BaCon's New Features or further on HUG BaCon editor ... red tags blue tags ... Tip images in a buffer = 1 char like 'A' BR Alex Attachments:
|
|
|
Post by alexfish on May 2, 2023 10:58:45 GMT 1
Grid / html table Calculator Time INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") OPTION UTF8 TRUE '======================================================= HOME$= GETENVIRON$("HOME") gtk$ = HUGLIB$("gtk") IMPORT gtk_text_view_set_cursor_visible (long,int) FROM gtk$ TYPE void IMPORT gtk_text_buffer_insert_pixbuf (long,long,long) FROM gtk$ TYPE void IMPORT "gtk_text_buffer_create_tag(long,char*,char*,...)" FROM gtk$ TYPE long IMPORT "gtk_text_buffer_insert_with_tags_by_name(long,long,char*,...)" FROM gtk$ TYPE void IMPORT "gtk_text_buffer_apply_tag(long,long,long,long)" FROM gtk$ TYPE void IMPORT "gtk_text_buffer_get_iter_at_offset(long,long,int)" FROM gtk$ TYPE void '======================================================= PRINT HUG_VERSION$ '======================================================= FUNCTION PARAGRAPH (int hug_xsize, int hug_ysize) LOCAL buffer, view, here
buffer = gtk_text_buffer_new(0) view = gtk_text_view_new_with_buffer(buffer) gtk_text_view_set_editable(view, 0) gtk_text_view_set_wrap_mode(view, 3) gtk_text_view_set_cursor_visible(view,FALSE) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(view)
hug_widget_xsize(STR$(view)) = hug_xsize hug_widget_ysize(STR$(view)) = hug_ysize hug_widget_signal(STR$(view)) = 5 hug_widget_s_widget(STR$(view)) = buffer
hug_widget_type$(STR$(view)) = "edit" hug_widget_font(STR$(view)) = view hug_widget_focus(STR$(view)) = view WIDGET = view
RETURN view
END FUNCTION '======================================================= SUB BLUETAG(long hug_widget,int start,int end) A$ = GRAB$(ed) LOCAL iters,itere,buf,pixbuf buf = hug_widget_s_widget(STR$(hug_widget)) iters = MEMORY(HUG_DEFAULT_WIDGET_SIZE) itere = MEMORY(HUG_DEFAULT_WIDGET_SIZE) gtk_text_buffer_get_iter_at_offset(buf,iters,LEN(A$)-start) gtk_text_buffer_get_iter_at_offset(buf,itere,LEN(A$)-end) 'gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iters) tag = gtk_text_buffer_create_tag(buf,"blue_foreground", "foreground", "blue", NULL) 'gtk_text_buffer_insert_with_tags_by_name(buf, iters,"This", tag, NULL) gtk_text_buffer_apply_tag(buf,tag,iters,itere) FREE iters FREE itere END SUB '======================================================= SUB INSERTIMAGE(long hug_widget,STRING hug_text$) LOCAL iter,buf,pixbuf buf = hug_widget_s_widget(STR$(hug_widget)) pixbuf = gdk_pixbuf_new_from_file(hug_text$, 0) iter = MEMORY(HUG_DEFAULT_WIDGET_SIZE) gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iter) gtk_text_buffer_insert_pixbuf(buf,iter,pixbuf) g_object_unref(pixbuf) FREE iter END SUB '=======================================================
win= WINDOW("para",806,606) Paragraph1 = GRID(200,200) ATTACH(win,Paragraph1,3,3) ed= PARAGRAPH(200,100) GRIDATTACH(Paragraph1,ed,0,0,1,1) TEXT(ed,"HELLO WORLD" & NL$) TEXT(ed,"Have Fun playing with HUG") INSERTIMAGE(ed,HOME$ & "/test12.png") TEXT(ed,NL$) TEXT(ed,"See you at Basic Converter Forum HERE" & NL$) BLUETAG(ed ,4,0)
ed= PARAGRAPH(200,100) GRIDATTACH(Paragraph1,ed,1,0,140,1) TEXT(ed,"HELLO WORLD2" & NL$) TEXT(ed,"Have Fun More fun playing with HUG") INSERTIMAGE(ed,HOME$ & "/test12.png")
TEXT(ed," We Are WHERE" & NL$) BLUETAG(ed ,5,0)
'======================================================= DISPLAY '======================================================= tip to complete a tag at end of line use NL$ if link is a NO BREAK set edit to NO WRAPneed to calculate <span> use extents Will post a howto next Post: do not break next postThanks + Have Fun + BR Alex Attachments:
|
|
|
Post by alexfish on May 2, 2023 18:44:03 GMT 1
Font and font extents
Cairo ' default font Mono Space ' default font_size USES px pixel : 16px
IE setting fonts if pixel based , that relates to sizes say textbox(600,16) Font "Mono Space 16px"
so here using cairo, since it is built in
INCLUDE "hug351.bac" HUGOPTIONS("NOSCALING") '====================================================================== OPTION UTF8 TRUE '====================================================================== cairo$ = HUGLIB$("cairo") 'Requires IMPORT cairo_text_extents(long,const char*,void*) FROM cairo$ TYPE void
'====================================================================== FUNCTION TEXT_WIDTH(long cr, hug_text$) TYPE double
RECORD extent LOCAL x_bearing TYPE double LOCAL y_bearing TYPE double LOCAL width TYPE double LOCAL height TYPE double LOCAL x_advance TYPE double LOCAL y_advance TYPE double END RECORD
cairo_text_extents (cr,hug_text$,&extent) RETURN extent.width END FUNCTION '====================================================================== FUNCTION TEXT_HEIGHT(long cr,hug_text$) TYPE double
RECORD extent LOCAL x_bearing TYPE double LOCAL y_bearing TYPE double LOCAL width TYPE double LOCAL height TYPE double LOCAL x_advance TYPE double LOCAL y_advance TYPE double END RECORD
cairo_text_extents (cr,hug_text$,&extent) RETURN extent.height END FUNCTION
'====================================================================== ' Main '====================================================================== LOCAL surf,cr LOCAL text_width,text_height TYPE double
surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,200,100) cr = cairo_create (surf) ' default font Mono Space cairo_select_font_face (cr,CAIROFONT$,0, 0) ' default font_size USES px pixel cairo_set_font_size(cr,CAIRO_FONT_SIZE) LOCAL A$ TYPE const char* A$ = "Hug With and Heigh" text_width = TEXT_WIDTH(cr,A$) text_height = TEXT_HEIGHT(cr,A$)
PRINT "Dims : " ,text_width , " x " , text_height cairo_destroy(cr) 'surface may want to reuse or what ever cairo_surface_flush(surf) ' if not destroy it
'=END All That===========================================================
Here I get 178 x 15
BR Alex
|
|
|
Post by alexfish on May 2, 2023 18:54:09 GMT 1
Q: I use Pango A: pango use same system fonts So Pango "Mono Space 16px" is same as Cairo "Mono Space 16px" Nearly forgot EDIT default vertical spacing is 3 , I think says he In some cases that may be different , check it so if 3 the vertical spacing on 16px = 19 : check it Why Mono Space 0 2x0 == 00 0 there again some modern variants, design wise , the designer don't know the what Mono Space had Clueless Mono Space with O0O0 thats big o and zero twice Thinking this a waste of time here extents wise , font sizes are like for like GTK3 OK , think this is due to this Allocation , space wise looking at this grid ,see if find the Width pixel Argh Just remembered / hug fontsize FACTOR Arggh There's a one in that font pick , some designers don't know what a zero is cos there ain't a zero in some of those fonts Probably they failed at math's Attachments:
|
|
|
Post by alexfish on May 2, 2023 21:52:49 GMT 1
Sorted + worked out left hand margin = 3 so ed= PARAGRAPH(text_width+3,100) did not check the height but the text width of "See you at Basic Converter Forum HERE" will wrap without the +3 BR Alex update to follow:: original hug has table with no factors( in the (Window make) but if no table FONT FACTORS ARE AT WORK , when attaching the grid Choices MM :: an AlexGrid Back Soon picky text extents with +1 shows wrapped ed= PARAGRAPH(text_width+1,100) and the +3 not wrapped if examine the picky the end of E in HERE is right on right hand limit of the VIEW BR Alex Attachments:
|
|