|
Post by alexfish on Jul 1, 2019 11:52:34 GMT 1
Hi All
Something like a staging post update on using html5tidy as a html scraper with interactive mode
so here taking a well documented form with input
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Form Calculator Add Example</title> </head> <body> <form name="myForm" action="" onsubmit="return calc(this['A'].value,this['B'].value);" method="post"> <input type="text" name="A"> <input type="text" name="B">= <span id="result"></span> <br> <input type="submit" value="Submit"> </form> <script> function calc(a,b){ var a = document.forms["myForm"]["A"].value; var b = document.forms["myForm"]["B"].value; document.querySelector("#result").textContent = Number(a)+Number(b); return false; } </script> </body> </html>
when the interface is in iteractive mode then when met with INPUT
the a request for in put happens;
and interesting to note where tidy buts the bits into CDATA ? from the above form
The results from the terminal
here i enter the number @ Input A : and so on;
<!DOCTYPE html> Form Calculator Add Example Input A :90 A = 90; Input B :20 B = 20;= script /n<script> <![CDATA[ function calc(a,b){ var a = document.forms["myForm"]["A"].value; var b = document.forms["myForm"]["B"].value; document.querySelector("#result").textContent = Number(a)+Number(b); return false; } ]]> </script> script /n function calc(a,b){ var a = document.forms["myForm"]["A"].value; var b = document.forms["myForm"]["B"].value; document.querySelector("#result").textContent = Number(a)+Number(b); return false; }
From these bits have a nodejs writer parser to complete the task if have node / nodejs on board
as an example
can pass the values a & b to a js script
IE like this
var a = 90; var b = 20; console.log(a+b);
and the result from the terminal
node test.js 110 the test.js
also at this staging now have method to pack the table & or Grid and method to print the bits
although off beat with c++ ;;a simple example of c type array [][];
typedef vector<string> Vstr;
Vstr vv(5); vector<Vstr> table4(4, vv);
fill some bits in
table4[0][2]= "This"; table4[1][3]= "that"; table4[3][0]= "one"; table4[3][1]= "two"; table4[3][2]= "three"; table4[3][3]= "four"; table4[3][4]= "five";
a simple writer function to demo
void SPrintTable (const vector<vector<string> >& table){ for (int i = 0; i < table.size(); i++) // loops through each row of vy { for (int j = 0; j < table[i].size(); j++) // loops through each element of each row cout << table[i][j] << "|"; // prints the jth element of the ith row cout << endl; } }
example output
||This||| |||that|| ||||| one|two|three|four|five|
BR Alex
|
|
|
Post by alexfish on Jul 1, 2019 14:37:24 GMT 1
With the test form input in action from the console running js
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Form Calculator Multiply Example</title> </head> <body> <form name="myForm" action="" onsubmit="return calc(this['A'].value,this['B'].value);" method="post"> <input type="text" name="A*"> <input type="text" name="B">= <span id="result"></span> <br> <input type="submit" value="Submit"> </form> <script> function calc(a,b){ var a = document.forms["myForm"]["A"].value; var b = document.forms["myForm"]["B"].value; document.querySelector("#result").textContent = Number(a)*Number(b); return false; } </script> </body> </html>
<!DOCTYPE html> Form Calculator Multiply Example A*B= Input : 9 Input : 20 Result =180
& Now With the submit active:
<!DOCTYPE html> Form Calculator Multiply Example A*B= Submit Input : 9 Input : 10 Result =90
floating point js
<!DOCTYPE html> Form Calculator Multiply Example A*B= Submit Input : 78.56 Input : 34.67 Result =2723.6752
BR Alex
|
|
|
Post by alexfish on Jul 1, 2019 15:08:50 GMT 1
and a final sum up of js
that type of math solve ok as regards html
JS was supposed to be the the one and one for all ,
opinion that was a 'crap' + bullshit statement; right down to Your Distro & version of C++;
Have a Nice day
Alex
|
|
|
Post by alexfish on Jul 3, 2019 17:19:00 GMT 1
Hi All Progress; table/grid formatting test now done : ready implement in the lib as a note to this have been testing callback features and one of those was Mouse as in button click. been on search for solution tried home brew from different sites gmp and slang and ncurses ; in main lack of info = not worth the effort , either the call back did not work or the buffer showed feedback from the mouse tracking; hence now got the table done ;; this table is auto resize on the width and auto formatting on header + data type. hence gave last shot at Ncurses today and I mean all day as in since yesterday as well phew ; how to get multi lines into Ncurses . and only respond to a button click all info show Mousetrack report ;; are well shot that lot into the bin about 2 hours ago; out with the header file . and Hi Presto . now got what will work well in interactive mode BR Alex the table bits and then a screen shot of a terminal with graphics with buttons click on the red bit and the app will close; terminal results ================================================================================================== Header 8 Header 9 Header 10 Header 11 Header 12 this date 200 120000 WHAT does this 1 5 is one two 1100 123 Work Mods : OK Bye ! Bye! ================================================================================================== ==================================================================================================================== Header 8 Header 9 Header 10 Header 11 Header 12 this date 200 120000 WHAT does this 1 5 is one two 1100 123 Work Mods : OK Bye ! Bye! ==================================================================================================================== ncurse view Attachments:
|
|
|
Post by alexfish on Jul 4, 2019 19:20:56 GMT 1
Hi All Now sorted if option to use Ncurses Now I tried to find out how Ncurses was named , not much found but in en curse is apt , segfaults are easy to do , so have built in the safeguards and also done alignments no in process of finalising the lib , what you see here is the Ncurses + Image + the table testing redraw . the bacon image is align right so have to picky's BR Alex Attachments:
|
|
|
Post by alexfish on Jul 5, 2019 16:30:58 GMT 1
Hi All
As I never say Not again
Well had another last ditch attempt to get mouse control using just gpm
have set up to the termios to get the keys in non blocking
and set the gpm to start only with the default mask
now the call to the termios reads the mouse feed back via the keypads like left right up down home
anyway have set filter the get the bits ;but had problem with some of the mouse scroll & button down drag , their out put appears in the stream
have just now sorted a fix by doing a terminal delete line
the bits shows a shift to the right on the info
so here indicating where the button press event happen in terminal row column
======================================== :91: :77: :97: :59: xpos :54: ypos ==================== :91: :77: :97: :58: xpos :54: ypos ==================== :91: scroll drag bit removed :77: :97: :58:xpos :54:ypos ==================== :91: :77: :97: :56:xpos :55:ypos ====================
take the xpos and ypos -32 will give actual true terminal cursor position
Hooray ;now have that bit sorted
BR Alex
|
|
|
Post by alexfish on Jul 8, 2019 22:54:05 GMT 1
Hi another bit in the chain 'fonts' in previous lib had utf8 to code point;; this now in use as regards fonts , much info wise , but of old , as the we here have past knowledge of getting fonts to render , the terminal sets a challenge but almost there as in getting a ttf2sixel font done, just got to render this letter B 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0011000010000000 0100000010000000 0100100100000000 0100101100000000 0100001000000000 0011010111000000 0000110000100000 0000101000100000 0001001000100000 0011000100100000 0010000111000000 BR Alex
|
|
|
Post by alexfish on Jul 9, 2019 3:16:07 GMT 1
Noticed the grim smililies above
did find a problem getting the bits out of using get index via 'char'
now using dif method
this = %
111 1 11 11 1 11 11 1 11 11 11 11 1111 11 1111 111 1 111 11 1 111 11 11 11 1 11 11 1 11 1 1 111
now I be a happy man
since can convert that directly in memory
1111 1 111 11 11 1 11 11 11 11 11 11 11 11 11 11 1 11 11 11 1 1111
1111 111 11 1 11 1 11 1 11 11 1111 11 1 11 11 11 11 11 11 11 11 1111 111
BR Alex
|
|
|
Post by alexfish on Jul 9, 2019 17:40:19 GMT 1
Hi All now have managed to get the kenrning & Accent to base line sorted
example output from the terminal
---------------- ---------------- ---------------- ---------------- ---------------- ---------------- ---------------- --111111--1111-- --111111--1111-- 1111----1111---- 1111----1111---- 1111----1111---- 1111----1111---- --1111111111---- --1111111111---- --------1111---- --------1111---- --1111111111---- --1111111111----
---------------- ---------------- ---------------- --------1111---- --------1111---- ---------------- ---------------- ------111111---- ------111111---- --------1111---- --------1111---- --------1111---- --------1111---- 1111----1111---- 1111----1111---- 1111----1111---- 1111----1111---- --11111111------ --11111111------
Added Sorted the transpose matrix to suite sixel format
Example of 'h' & 'H' out put chars to terminal using lib freetype
000000000000000000000 000001111111111000000 000001111111111000000 000000000110000000000 000000000100000000000 000000001000000000000 000000001100000000000 000000001111111000000 000000000111111000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000001111111111000000 000001111111111000000 000000000110000000000 000000000110000000000 000000000110000000000 000000000110000000000 000001111111111000000 000001111111111000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000 000000000000000000000
BR Alex
|
|
|
Post by alexfish on Jul 9, 2019 19:17:01 GMT 1
Looking at the resulting data
will have to do the usual Flip Image
explained the ~ to the right is the bottom line then each horizontal line = vertical line of sixel binary data also by this method can now compose a string of letters or words
both explained by this;
1111 ~ 111111 ~ 11 11 ~ 1 1 ~ 11 11 ~ 111111111 ~ 111111111 ~ 11 ~ 11 ~
~ 1111111 ~ 11111111 ~ 111 11 ~ 111 11 ~ 11 11 ~ 11 11 ~ 11111111 ~ 1111111 ~
thought put some theory to the test
here is same font but smaller
1 ~ 1 ~ 1111111 ~ 1111111 ~ 1 ~ 1 ~
have seen a lot of example on how to get the bits yet here the above was ttf font decode and render / transform from where I sit looks like the below although do not take all the api to heart since some of the FT_blagh are new Macro Functions to get the Job Done. Sixel Wise
BR int Base_Line;
// Base_Line Base_Line = HEIGHT - HEIGHT / SIXEL;
FT_Library library; FT_Face face; /* handle to face object */
int error = FT_Init_FreeType( &library ); if ( error ){ Print "... an error occurred during library initialization ..." } // set font path error = FT_New_Face( library, "/examples/sans2.ttf",0,&face ); if ( error ){ Print "... an error font file not exist..." return 1; }
error = FT_Set_Sixel_Sizes( face, /* handle to face object */ SIXEL_WIDTH, /* pixel_width */ SIXEL_HEIGHT ); /* for sixel height = width */ if ( error ){ Print "... an error font size set..." }
FT_GlyphSlot slot; slot = face->glyph; FT_UInt index = FT_New_Index(face,'T'); FT_Load_Char( face,index, FT_LOAD_RENDER ); Render_Sixel( &slot->bitmap, slot->bitmap_left, Base_Line - slot->bitmap_top ); SprintSixel(); FT_Done_Face ( face ); FT_Done_FreeType( library );
Alex
|
|
|
Post by alexfish on Jul 10, 2019 16:17:43 GMT 1
Hi All testing the string output buffer for the new school ./test pxibm92x.ttf 'Tide is turning' +++++++++ +++ ++++ +++ ++ +++ +**+**+** +** ++** +** +** +** ++ +** ++ ++++ ++*** ++++++ ++++ ++++++++ ++***++ +++ +++ +++++++ +++++++ ++++ +++++++ +++++++ +** ++** ++**+** +**++*** ++** +***++++ +++**++ +** +** ++*+*+*+ ++**++** ++** ++**++** +**++**+ +** +** +** +** +**+++++ +** ++**+ +** +** +** +** +** +** +** +** +** +** +** +** +** +** +** +** +** +++ +** +++ ++*+ +**+++ +** +** +** +** +** +** +** +** +** +** +***+ +***+ +**++*+ ++****++ +***+ ++****++ ++**++ ++**++*+ +***+ +*+ +*+ +***+ +*+ +*+ ++***** +++ +** ++***++
|
|
|
Post by alexfish on Jul 11, 2019 1:43:56 GMT 1
Hi All this my first attempt at hello world ttf2sixel not perfect as regards row stride but it works a small small font buts can see from the above getting a bigger font in the terminal is an eyesore can not post the bits with esc commands so here have text codes and full bit in archive Pq"1;1;80;18#0;2;0;0;0#1;2;97;97;97#1}}}~~~^^!12~^^^!4~^^^!39~^^^!8~$#0@@@???__!12?___!4?___!39?___-~~!4?~~CC{w?w{SS[W???~!6?~!4?w{CC{w!7?C{_ww_{?w{CC{w?CC{[CC???~!4?w{CC$#1??!4~??zzBF~FBjjbf~~~?!6~?!4~FBzzBF!7~zB^FF^B~FBzzBF~zzBbzz~~~?!4~FBzz-#0FF!4?BB??BB?@BAAA!4?BBA!4?BBA??@BAAB@!8?BB@BBB?@BAAB@?AABAA!4?BBA??@BAA$#1ww!4~{{~~{{~}{|||!4~{{|!4~{{|~~}{||{}!8~{{}{{{~}{||{}~||{||!4~{{|~~}{|| to view the image in terminal xterm start xterm -ti 340 cat test.six mlterm just cat the image the picky Attachments:
test.six.bz2 (258 B)
|
|
|
Post by alexfish on Jul 11, 2019 13:50:54 GMT 1
Hi All
As a final wrap on the terminal drivers
From the bits Now can get ttf fonts into the terminal : hence if html font = blagh And size = blagh And color = Blagh
now have the bits to do it;;
as for working in memory :: need to transpose the data to sixel by dividing the bits into 6 bits
and color ONLY That Pixel
as a guide the below shows rows of data , the Top ' Row right hand column = Left Column bottom ;
Twist Your head to see what is going on with transforming of the Matrix To Sixel ; "Lgy"
* * * + * 11111*111111*1 + * 11111*111111*1 + * 11111*111111*1 + * * 1*1 + * * 1*1 + * * 1*1 + * * 1*1 + * * 1*1 + * * * +
* 1*11 * 111 + * 11*111 11* 1111+ * 111*111111*1 111+ * 11 * 11111*1 11+ * 11 * 11 1*1 11+ * 11 * 11 1*1 11+ * 111*1111 1*11111+ * 1111*111 1*1111 + * 11 1*11 *1111 + * 1 * * +
* 11 * * + * 111*11 * 11+ * 111*111111* 111+ * *111111*1 11 + * * 11*1111 + * * 1111*111 + * 11*111111*1 + * 111*1111 * + * 111*1 * + * * * +
Added Run "i" Through the bits
?? o? o? p? r~ r~ @? ?? ?? ??
then those bits get transposed as in Transform matrix
some of the buffer with i in before the above
000000111100000 000000011000000 000000000000000 000000000000000 000011111000000 000011111000000 000000011000000 000000011000000 000000011000000 000000011000000 000000011000000 000000011000000 000011111111000 000011111111000 000000000000000 000000000000000 000000000000000 000000000000000
BR Alex
Final comment as regards using ttf fonts in a buffer looks like there is a buffer stride limit in terminals : looks like 1024 pixy there again can put say a table in and that table will not wrap
|
|
|
Post by alexfish on Jul 13, 2019 16:40:44 GMT 1
The module ttffont2sixel is now complete New html2text lib will be in about 2 weeks : need to tie up the table bit with font sizes -> advance++ vovchik also knows about Advance Final screen shot of ttffont2sixel BR Alex
|
|
|
Post by alexfish on Jul 14, 2019 9:04:59 GMT 1
Hi All
Not sure if this is relevant to PI
the above code works in mlterm and not xterm
thinking here that on RPI mlterm max print stride(width) = 1024
the relevant 'Peter's xterm universal toolkit' as in pushing xterm to the limit does not work work on RPI
have tried compiling xterm sources with prefix --sixel and results are the same
Updated
this is something to do with sixel header so looking further at sixel version & or to the reason
BR Alex
|
|