Nim to JavaScript compile: function ref

2020-01-10 Thread Peter
I'm trying to compile Nim source to JavaScript. I use a simple (partial) Nim 
wrapper for Dygraphs library and I create some graphs from my Nim code. The 
problem is that I don't understand ho to pass to Dygraphs an option with the 
function reference. In Javascript it should be like this:


  
  new Dygraph(
  document.getElementById("div_g"),
  data,
  {
labels: ['X', 'Est.', 'Actual'],
animatedZooms: true,
underlayCallback: function(canvas, area, g) {
  var bottom_left = g.toDomCoords(highlight_start, -20);
  var top_right = g.toDomCoords(highlight_end, +20);
  
  var left = bottom_left[0];
  var right = top_right[0];
  
  canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
  canvas.fillRect(left, area.y, right - left, area.h);
}
  
  }
  );



Run

How should I define underlayCallback in Nim and how should I declare this 
option in wrapper?

My wrapper is here: 
[https://raw.githubusercontent.com/Peter2121/noogest/master/dygraph.nim](https://raw.githubusercontent.com/Peter2121/noogest/master/dygraph.nim)

I create the graph from another module like this:


var opts = NimDygraphOpts()
...
tempGraphs[channel] = newDygraph(parent,cData,opts[])


Run

So, probably, I need to declare a new option in NimDygraphOpts object, set it 
to some function pointer and then pass it to newDygraph. But I dont't 
understand what type of object should I use for this option and how should I 
assign it.


Re: Cannot build old project - TChannel problem

2019-12-25 Thread Peter
Thanks a lot, it compiles with Channel.


Cannot build old project - TChannel problem

2019-12-25 Thread Peter
Hello,

I'm trying to build an old project, created with 0.11.2 version, using Nim 
1.0.2. I'm blocked with the following error:

Error: undeclared identifier: 'TChannel'

I'm using the following options to build the project:

\--threads:on --opt:none --debuginfo --gc:markAndSweep|   
---|---  
  
How can I solve the problem? Is TChannel deprecated? 


Redirect stdout

2019-10-13 Thread Peter
Hi, I am not an expert in Nim programming, I need some help ;) I want to create 
a small GUI wrapper around two console tools using Nim and nfltk module. The 
GUI process should start two console tools and catch their output, so I will be 
able to update their status in my GUI in realtime. The tools will run until I 
stop them (or they crash). I searched Nim standard lib, but I'm lost between 
execProcess, startProcess, execCmd etc. And anyway I cannot find a method of 
catching stdout to update the status in real time. Please, help. Peter