Hi Julian,
I tried about two years ago to drop my jig interface into JHS. Jig develops an
SVG file that contains extra information that the user can reveal by hovering
over elements of the display. It is an addon for jqt updated and running for
version 805 to 902. Brief video intro https://youtu.be/dK1y_V07214
Anyway, since JHS is already HTML, I thought that it should not be too hard to
incorporate the SVG display into JHS. What I tried was prepending the input
line with a verb that would activate jig and strip the prepended verb off for
the line display so that the SVG output displays instead of the usual text.
Although, I did get it working after a fashion by making some changes to the
input_jhs_ and output_jhs files, I found the process pretty confusing and never
really grokked the process well enough that I wanted to make it anything that
anyone else would use. I felt I was missing something obvious and if you find
it I would be very interested in your results.
Here is the input and output alterations that I tried. 'vis' is the verb that
was prepended to the original input. Be very careful with your changes as this
is affecting the interaction that you have as the program runs. It is a bit
like trying to build the airplane in mid-flight.
input_jhs_=: 3 : 0 NB. Rewriting of input_jhs_ to allow 'vis ' to be prepended
to input to create svg jig result
logapp 'jhs input prompt: ',":#y
try.
if. _1~:SKSERVER do. try. ".'urlresponse_',URL,'_ y' catch. end. end. NB. jijx
if. _1~:SKSERVER do. jbad'' end.
getdata'' NB. get and parse http request
if. 1=NVDEBUG do. smoutput seebox NV end. NB. HNV,NV
if. -. ((<URL)e.boxopen OKURL)+.(cookie-:gethv'Cookie:')+.PEER-:LOCALHOST
do. r=. 'jev_get_jlogin_ 0'
elseif. 1=RAW do. r=. 'jev_post_raw_',URL,'_'''''
elseif. 'post'-:METHOD do. r=. getv'jdo'
elseif. '.'e.URL do. r=. 'jev_get_jfilesrc_ URL_jhs_'
elseif. 1 do. r=. 'jev_get_',URL,'_'''''
end.
logapp 'jhs sentence: ',r
if. JZWSPU8-:3{.r do. r=. 3}.r end. NB. empty prompt kludge
if. ' '-: r do. '6 vis LF' return. end. NB. empty line
if. JIG_jig_ *. -.('jig '-:4{. dlb r)+.('0 jig '-:6{. dlb r)+.('jev_'-:4{. dlb
r) NB. J sentence to run, jig , 0 jig, jev_, blank are exceptions
do. r_jig_=.r
cocurrent LOC_jig_
try.
if. _1~:t_jig_=.nc <r_jig_
do. try. t_jig_=. nc <'prox_jig_' [ ".'prox_jig_=.',r_jig_
catch. t_jig_=._2 end. end.
catch. t_jig_=.nc <'r_jig_' end.
cocurrent 'jhs'
select. t_jig_
case. _2 do. '_2 vis ''',r_jig_,''''
case. _1 do. '_1 vis ''',r_jig_,''''
case. 0 do. '0 vis ',r_jig_
case. do. (":t_jig_),' vis ''',r_jig_,''''
end.
else. r end. NB. non jig result always displayed as text
catch.
logappx 'input error'
exit'' NB. 2!:55[11 crashes
end.
)
output_jhs_=: 4 : 0 NB. Rewriting of output_jhs_ to strip 'vis ' from output
result
logapp 'output type : ',":x
if. 5=x do.
jhrajax'<font style="color:red;"><pre>',jhsexit,'</pre></font>'
jfe_jhs_ 0
2!:55[0
end.
try.
s=. y NB. output string
type=. x NB. MTYO type
class=. >type{'';'fm';'er';'log';'sys';'';'file'
if. (6=type)*.URL-:'jijx' do.
t=. jhtmlfroma s
if. '<br>'-:_4{.t do. t=. _4}.t end.
LOGN=: LOGN,'<div class="',class,'">',t,'</div><!-- chunk -->'
LOG_jhs_=: LOG,LOGN
if. -.CHUNKY do.
jhrajax_a LOGN
else.
jhrajax_b LOGN
end.
LOGN=: ''
CHUNKY_jhs_=: 1
elseif. (3~:type)+.-.('jev_'-:4{.dlb s) do. NB. jev_... lines not logged
if. (-. JIG_jig_) +: ('jig '-:4{.dlb s)+.('0 jig '-:6{. dlb s)+.(*./' '=s)
NB. jig only if JIG flag and not 'jig' command or empty line
do.
if. 3=type do.'noun visjig'=. 2{. ;: s
s=. (2* 'vis'-:visjig )&}. &. ;: s
s=. PROMPT, dlb (}.@:(_3&}.))^:(0 ~: ". noun) s end. NB. vis
that was prepended in input removed to avoid display on input line
else. if. 3=type do.
if.('6'-:{.s) do. s=. '' else. s=. PROMPT,dlb s end. end. NB. 6
empty prompt case from input, necessary for when jig is deactivated
end.
t=. jhtmlfroma s
if. '<br>'-:_4{.t do. t=. _4}.t end.
LOGN=: LOGN,'<div class="',class,'">',t,'</div>'
end.
catch.
logappx'output'
exit''
end.
)
Good luck with your project.
Cheers, bob
> On Aug 23, 2020, at 05:29, Julian Fondren <[email protected]> wrote:
>
> Howdy,
>
> I'm really liking JHS as a rich console with its ability to
> inline plots and arbitrary HTML elements, where other frontends
> would have to use a separate window.
>
> jhtml'<img src="~temp/generated_fractal.png">'
>
> I have some complaints about it though, and the biggest one is
> that the editor doesn't have qtide's Run menu with its line
> evaluation commands.
>
> I've worked with ide/jhs/jijs.ijs enough to think that I
> can add line evaluation after a fashion. But, has anyone
> already done this?
>
> Nice-to-haves are
>
> - evaluating the line as interactive input instead of going
> through load__
>
> - properly evaluating lines that include 0 :
>
> - updating the /jijx tab, to see the results of evaluation,
> without having to hit enter in it first
>
> Does anyone have any other customizations of JHS like this?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm