- COPYRIGHT & LICENSE
Text::Editor::Easy::File_manager - Management of the data that is edited.
By complexity order, this module, I think, is the third.
If you create a "Text::Editor::Easy" object, this module will be called very often (but you don't even have to know that this module exists, thanks to "Text::Editor::Easy::Comm").
It manages "file" or "memory" data in a very lazy way. Too lazy for now. I'm going to ask more to this module soon.
You can read data from the start of the file, from the bottom, from the middle, ... from where you want in fact. I just use the "seek" instruction for that. You can read a line, its next or its previous.
This module is lazy because it doesn't read the file even once. I will change this to compute the line number and put some references in order to access faster to a given line number (with an interuptible long task at start).
If you modify a line that is on a file, well it has to work (reluctantly !). It puts the line in memory and will never fetch this line any more from the file.
When you save a modified file, it reads data from the initial file (for non-modified lines) or from memory (when modified), create a new file and when finished, move the new file to the initial.
There is a little drawback : you need more disk space than an Editor which would load everything into memory. The big advantage is that this module don't waste time reading uninteresting data : it reads only on the file the part you can see on the screen. Said like that, this seems obvious not to ask more to your computer. But most Editors think it's useful to read everything (well, it's surely because most programmers don't want to manage the complexity !). And when the file is huge, your entire system blocks. This seems stupid, because who is able to watch several Go of text data in a single day ? Well, I should say in a single year : but, nowadays, with cheap hard drives, most people don't know any more what can contain 1 Go of text data.
Return the line of a Text::Editor::Easy instance given its number. This task may be long for the moment (with huge file), so lazy mode is possible. At the beginning, this task was done outside this module, because sub "anything_for" was not written. Lazy processing can now be transmitted between threads : this means that one thread can stop its processing if another thread receives a new task.
Return the line of a Text::Editor::Easy instance and the position (start and end) in this line that match the regexp given. This task may be long (with huge file), so lazy mode is possible.
Copyright 2008 Sebastien Grommier, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.