Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roff preview? #3

Closed
bronson opened this issue Sep 19, 2016 · 21 comments
Closed

roff preview? #3

bronson opened this issue Sep 19, 2016 · 21 comments
Assignees
Milestone

Comments

@bronson
Copy link

bronson commented Sep 19, 2016

The screenshot in the README makes me think you have a preview mode that I can see in Atom? I'm looking for something like the continually-updated Markdown Preview.

Looking at the code, though... I guess this plugin contains syntax files and snippets, and I still need to escape to the terminal to preview?

@Alhadis
Copy link
Owner

Alhadis commented Sep 19, 2016

I suppose I could always make one. Wouldn't be terribly hard, I think. Just a case of piping Groff's output to Atom like a postprocessor. :)

@Alhadis
Copy link
Owner

Alhadis commented Sep 19, 2016

I'll see what I can do, mate.

@Alhadis Alhadis self-assigned this Sep 19, 2016
@Alhadis
Copy link
Owner

Alhadis commented Nov 19, 2016

Hey @bronson, just letting you know I've not forgotten about this. :) Trying to get work finished on the file-icons package, then I'll make a bee-line for this. I've already made a start.

I have the worst track record of starting projects and putting them down to start another...

@bronson
Copy link
Author

bronson commented Nov 19, 2016

No worries, I really like file-icons too. Gotta admit, given the popularity difference between roff and icons, your time might be better spent over there. :)

@Alhadis
Copy link
Owner

Alhadis commented Dec 29, 2016

Alright, all done! Lot of work, as you can see. Now then... let's get some roff happenin'. :)

EDIT: Okay, erm, maybe later. I spoke too soon... bloody Nuclide. :(

@Alhadis Alhadis added this to the v1.3.0 milestone Mar 1, 2017
@arbourd
Copy link

arbourd commented Mar 21, 2017

Hey @Alhadis, would this be part of the package or are you working on a separate package? Are you accepting pull requests?

@Alhadis
Copy link
Owner

Alhadis commented Mar 21, 2017

I'm making every effort to get around to it, but so far I've had to fight through urgent crap with file-icons. All concerning things outside my control:

  1. Updated file-icons to not break from jQuery removal in core packages
  2. Separated filesystem API so weird compatibility bugs can be investigated easier
  3. Now republishing a module because I found I had to deal with this shit at the last minute (literally):

Fuck APM

  1. Meanwhile, the release notes of file-icons v2.1.0 are chillin' there rather awkwardly waiting to be visible to the Atom community. Stuff like this happening all the time, for weeks. I'm doing all I can to get around to this, it's my incentive for tolerance.

No pull-requests, sorry. I'm way too much of a control freak; and this is actually really complicated, but it's just a matter of focus. It'll be in this package, don't worry.

@arbourd
Copy link

arbourd commented Mar 21, 2017

Thanks for the immediate response!

No worries. I appreciate the effort you make towards the Atom community. G'luck with file-icons. :)

@Alhadis
Copy link
Owner

Alhadis commented Mar 21, 2017

On the plus side, guess what? The roff-preview will be a full-blown real-time renderer for groff, capable of displaying actual typeset output.

It's not like it's avoidable. Due to the way troff defines output devices, it had to be done. Figure I may as well make this damn worth the effort.

@Alhadis
Copy link
Owner

Alhadis commented Mar 31, 2017

@arbourd You can track progress on the renderer branch. =) As you can see, it's... uh, quite involved.

Bonus: Will be able to convert tokenised output as SVG and Markdown. So far, so good. Shit is rock-solid.

@Alhadis
Copy link
Owner

Alhadis commented Apr 19, 2017

Halfway there. =)

EDIT: More than halfway:

Figure 1

@Alhadis
Copy link
Owner

Alhadis commented Apr 28, 2017

@arbourd Are you good with maths and/or trigonometry? I, erm, need help. I'm dyscalculic, and stuck on figuring out arc-drawing.

E.g., this code:

.PS
"+" at 0,0
arc -> from 0.5,0 to 0,0.5
arc -> cw from 0,0 to 1,0.5
arc -> cw from 0,0 to 2,0 rad 15
.PE

... should look like this in the previewer:
Figure 1

Instead, it's currently looking like this:
Figure 2

I only have these coordinates to go by:

  • startX, startY - Coordinates of the arc's starting point
  • centreX, centreY - Coordinates of the arc's centre
  • endX, endY - Coordinates of the arc's terminal point

But the canvas arc requires all of these:

  • x - The x coordinate of the arc's centre.
  • y - The y coordinate of the arc's centre.
  • radius - The arc's radius.
  • startAngle - The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  • endAngle - The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.

The part with radii and angles is what's killing me... 😢

@tmpdubz
Copy link

tmpdubz commented Apr 28, 2017

Hi @Alhadis! I'm a friend of @arbourd and also a mathematician. I present a solution if you still require it!

That being said...

Alright! Euclidean Geometry! Game on!

So you've got a few things going on here, I'm sure you've figured out that...

  1. the radius is: sqrt((startX - centreX)^2 + (startY - centreY)^2)
    (or you could use end* in place of start*)

  2. Now for the angles!

You'll need a way to compute the angle measured clockwise from the x-axis for any general point.

Luckily, you have inverse trig functions!

(I did my test calculations with atan2: [https://en.wikipedia.org/wiki/Atan2])

Let's set this up a bit first:

If tan(theta) = y/x, then the inverse trig function arctan(y/x) = theta, you have 2 points, so that doesn't work as arctan will only accept 1 point as an argument and give you back the angle from the x-axis.

You'll need to do the following computation for both the start point and the end point.

Begin by translating the non-centre point by the same transformation you would apply to bring the centre of the circle to the origin:


startXnew = (startX - centreX)
startYnew = (startY - centreY)

Then compute arcttan(startYnew / startXnew), this is your startAngle.


As stated before, the same process applies for the end angle.

CAVEAT! arctan is periodic, so if your arc crosses the positive x axis, there is a chance that you may get some odd behaviours. If this is the case, and it gives you trouble, I'd be happy to help.

I hope this was clear and helpful and not too excessive! Best of luck!

@Alhadis
Copy link
Owner

Alhadis commented Apr 28, 2017

Oh wow, thank you! This was much more help than I expected... and a lot for my poor little head to take in, but I'm trying. Some generous folks on Groff's mailing list have also extended their help. I'm going through everything now, but plotting it on paper to help me visualise it.

Dyscalculia is part of what's making this so hard... 😢 The numbers in my head keep "slipping" when I try to follow them, so I keep getting lost in people's explanations.

I'll update once I finally figure this out... thank you so much again!!

@Alhadis
Copy link
Owner

Alhadis commented Jun 21, 2017

Right, finally realised why I've spent so long deliberating on implementation decisions. I've been developing two distinct projects in tandem with one another.

Say hello to Electroff. JavaScript-based Troff integration. It'll be worked into the Atom package as a dependency. Dunno if it'll be published to NPM under that name, though... because it's not strictly Electron-specific.

Anyway, we'll see. Need to get v1.3.0 released first, it's almost been a freaking year. ;p

EDIT: Okay, yeah, erh... better give that module a less wanky name...

@TriMoon
Copy link

TriMoon commented Jul 18, 2019

So how do we get to see previews of man pages?
I just installed this package in my atom-beta and don't see any options to preview the file i'm editing...
Any progress yet? 😸

edit: Nevermind, i found the "save-as" option finally...
This needs to change into a preview-pane with generated file in a tmp dir that gets updated/removed as you edit ofcourse i bet 😉

@Alhadis
Copy link
Owner

Alhadis commented Jul 18, 2019

It's literally nearing completion. Work on this is taking place over at the Roff.js repository, where I'm wrapping up surface-level APIs for loading and formatting files with groff (and by extension, man).

Everything is ready to go, it's really just me bikeshedding with myself and being a perfectionist. If you want a glimpse of what you'll be getting, you can checkout the Roff.js repository, and run electron on test/demos/canvas/umd.html. You'll get something like this:

Figure 1

... which is what a man page is supposed to look like. 😉 However, since we're all used to seeing them formatted for terminal display, you'll probably expect this instead:

Figure 2

Obviously, that'll be supported as an alternate display mode, but as you can see, it does little to show what Troff is really capable of... 😉

@Alhadis
Copy link
Owner

Alhadis commented Jul 18, 2019

There's an absurd amount of improvements, bug fixes, and features that've been added to language-roff since its last published release... which, erm, was back in February 2017. Before this project snowballed out of control and became worthy of a full-blown library of its own.

I've been itching for years to cut a release, but the current state of the master branch kinda blocks me from cutting one until the preview feature is finished. Which I've sworn to get done this year. Honest. 😅 The amount of work I've put into this project is unreal.

@Alhadis
Copy link
Owner

Alhadis commented Dec 31, 2019

Right, so I vowed to get this finished sometime this decade, and because I'm still having troubles with live-reloading, I've finally done what any sane developer would have already done long ago — release now, iterate upon it later. Something my completionist self doesn't understand very well.

You'll be able to view man pages inside Atom, but edits to Roff files won't show up in the preview automatically (long story short: Atom's APIs don't make it easy for implementing live views). Will probably fix this in a future release.

@bronson
Copy link
Author

bronson commented Dec 31, 2019

Still amazing work! Happy new decade. 🎉

@Alhadis
Copy link
Owner

Alhadis commented Feb 26, 2022

Happy new decade. 🎉

First COVID-19, then the BLM riots, and now war between Russia and Ukraine.

We sure jinxed the shit out of this decade, huh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants