I believe Erlang/Elixir can fit to any purpose.
I faced with an issue to move my cursor to the beginning of the line. I can’t find any suitable solution except using pread(IO, Location, N) with N window where
- read N bytes
- check if there is a
\n and repeat until reach
pread(file, offset - [i * N], N)
And how big should be N in that case?
What exactly do you mean by “cursor” and “beginning of line”?
Are you really writing in a file, or are you trying to manipulate the screen in a tty?
Are you writing a file editor?
It’s really hard to answer this question w/o the larger context of what you’re really trying to do.
If your terminal supports ANSI, you can use it to control the cursor very exact: http://ascii-table.com/ansi-escape-sequences.php
I am reading from the file on the file system.
By cursor I mean seeking/offset/caret/pointer/position/location in the opened file when you move your position by N bytes and read starting from this point.
I am writing a parser to parse some custom file format.
Then I’d suggest to either keep track of the offsets of the lines in the files or to write the parser in a way that it does not need to go backwards.
I’d prefer the latter.