News for hackers. Stuff that matters.
Re:Show HN: Primrose – A text editor that draws to Canvas by robertkrahn01 on Sunday January 04, 2015 @03:02AM (#8833810)
My project CodeChisel3D has a similar goal: http://robert.kra.hn/projects/live-programming-with-three-an...
Re:Show HN: Primrose – A text editor that draws to Canvas by brian_peiris on Sunday January 04, 2015 @10:50PM (#8837130)
moron4hire, robertkrahn01 funny for you two to meet here. I have been working on a solution for RiftSketch that is more like Robert's approach, where I use a canvas backed by an actual textarea (Robert's canvas is cleverly backed by an Ace Editor instance). Instead of re-implementing an editor from scratch, the user keyboard inputs are received by the textarea while the canvas and corresponding 3D texture are simply a re-rendered mirror of the textarea's contents and cursor/selection state. That way you can still rely on the usual editor mechanics (cursors, text selection, keyboard shortcuts, etc.).
Re:Show HN: Primrose – A text editor that draws to Canvas by moron4hire on Monday January 05, 2015 @12:16AM (#8837422)
How do you get the textarea, or any other element, into a canvas?
Re:Show HN: Primrose – A text editor that draws to Canvas by brian_peiris on Monday January 05, 2015 @06:18PM (#8841918)
I don't. The textarea remains hidden (off screen) in the background. It has the user's focus, so when the user types, it's receiving keystrokes as usual. Simultaneously, the render loop simply reads the text and selection state (selectionStart, selectionEnd) from the text area and renders the textarea's text and selection cursor/selection-highlight onto a canvas.
Re:Show HN: Primrose – A text editor that draws to Canvas by robertkrahn01 on Saturday January 10, 2015 @08:44PM (#8868711)
Same approach here. Except that I use the ace editor (http://ace.c9.io/) as the backend. This has the nice advantage that you get full code editing capabilities in 3D.