SOUR-Monkey
2005.05.29, 06:01 AM
Firstly, I must apologize for posting this here as opposed to iDA, unfortunately I can't seem to register there so for now I'll just have to plague iDG with non-game related posts. Very sorry.
Now for the problem: I want to be able to read in a man page and display it in a NSTextView with nice and pretty formatting, but it's proving to be somewhat more difficult than I expected initially. As you'd expect.
It would appear that man pages are formatted using one of the many *roff variations, which in itself is not too big a deal (although I must say, *roff formatting is pretty disgusting to look at). I could have simply written something that parsed the various tags and left it at that.
However, depending on whether the page is in a cat or a man directory, it uses a different style of formatting. This is not good, as it would mean I have to write two interpreters (I was not impressed with the prospect of having to write one).
The lazy-Sam solution is just to run system("man [page of interest]"); and chuck the result of that into my text view, but that doesn't allow me to do all the fancy formatting I would like to, and quite possibly won't even preserve the standard formatting done by man.
Bugger.
So, does anyone know how I should go about formatting the pages? I am sure that I will have to write my own interpreter if I want to do my own formatting (for the NSTextView), as any pre-written programs certainly won't do it for me. However, I'm having difficulty finding information on the exact format used for man pages, as all google searches just return pages and pages of man pages on man.
Of course, it's entirely possible that since I know nothing what-so-ever about *roff formats that I'm completely missing the whole thing and writing an interpreter is a fairly trivial (if time-consuming) process. I'm hoping someone somewhat more in-the-know than myself can enlighten me here.
So with no further ado, let the enlightenment begin!
Now for the problem: I want to be able to read in a man page and display it in a NSTextView with nice and pretty formatting, but it's proving to be somewhat more difficult than I expected initially. As you'd expect.
It would appear that man pages are formatted using one of the many *roff variations, which in itself is not too big a deal (although I must say, *roff formatting is pretty disgusting to look at). I could have simply written something that parsed the various tags and left it at that.
However, depending on whether the page is in a cat or a man directory, it uses a different style of formatting. This is not good, as it would mean I have to write two interpreters (I was not impressed with the prospect of having to write one).
The lazy-Sam solution is just to run system("man [page of interest]"); and chuck the result of that into my text view, but that doesn't allow me to do all the fancy formatting I would like to, and quite possibly won't even preserve the standard formatting done by man.
Bugger.
So, does anyone know how I should go about formatting the pages? I am sure that I will have to write my own interpreter if I want to do my own formatting (for the NSTextView), as any pre-written programs certainly won't do it for me. However, I'm having difficulty finding information on the exact format used for man pages, as all google searches just return pages and pages of man pages on man.
Of course, it's entirely possible that since I know nothing what-so-ever about *roff formats that I'm completely missing the whole thing and writing an interpreter is a fairly trivial (if time-consuming) process. I'm hoping someone somewhat more in-the-know than myself can enlighten me here.
So with no further ado, let the enlightenment begin!