0

[Context] I'm developing a little app, as a hobby to learn ncurses, that catalogs and lists and searches within a set of documents (for now, they are the HOWTOs from LDP).

The most tricky part of the app is, I believe, the file reader (show the contents of a file nicely). To really be able to provide a good enough user experience, given that the HOWTOs are somewhat long, it would be a valuable feature if I can "save" the line where the user stopped reading, and start on that same line the next time the user opens up that same HOWTO [/context]

So to the real question: is there a command-line reader that can not only get a line X as a parameter and position the cursor at that line, but also return the line that was last shown? Or, given that I'll be doing the call from a C app, maybe a different solution that's not an external app: I'm open to suggestions

beder
  • 1,086
  • 5
  • 10
  • Might be useful: http://superuser.com/questions/111016/vim-open-file-at-location-that-was-last-viewed or rereading your question maybe not :) – cowls Jan 08 '13 at 13:25

1 Answers1

1

but also return the line that was last shown

There is no portable solution to this. See Are there any standard exit status codes in Linux?. I.e.:

  • How would that program signal an error?
  • How would it signal success?
  • How would it signal line numbers larger than 255?
Community
  • 1
  • 1
Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130