View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
GROMMIER Sébastien > Text-Editor-Easy > Text::Editor::Easy::Line



Annotate this POD


New  1
Open  0
View/Report Bugs
Module Version: 0.49   Source  


Text::Editor::Easy::Line - Object oriented interface to a file line (managed in the background by "Text::Editor::Easy::Abstract" and "Text::Editor::Easy::File_manager").


Version 0.49


    my $line = $editor->number(4);
    print "Initial text of line number 4 : ", $line->text, "\n";
    $line->set('This will be the new content');
    if ( ! $line->displayed ) {
        $line->display( {'at' => 'middle'} );

If we except the print, you could have done the same thing writing this horrible line :

    $editor->number(4)->set('This will be the new content')->select({'force' => 'middle'});


"Editor" object will stand for "Text::Editor::Easy" object and "line" object will stand for "Text::Editor::Easy::Line" object.

Some of the methods of the "editor" object need a "line" object as parameter or return "line" object(s). You should never call yourself the "new" method of the "line" package to create "line" objects. First, you use an "editor" method that returns "line" object(s), and you provide the second "editor" method that need a "line" object with what you have received from the first call.

Note that 'line' instances are scalar references : you can't do anything with them except calling methods of the interface. Each 'line' knows which 'editor' it belongs to.



This method does not accept any parameter.

It returns undef if the line is not displayed. When displayed, it returns the ordinate of the bottom of the line. See also "top_ord". The ordinate is the pixel number from the top with a graphical user interface but will be the line number in console mode.


    $line->display( { 'at' => 32, 'from' => 'bottom', 'no_check' => 1 } );
    print "Bottom ordinate of line $line is : ", $line->bottom_ord, "\n"; # Should return 32...

This method accepts only one optional parameter which is a hash reference. The options that this hash may contain are described in 'editor display method' as the second parameter.

To display an editor, you have to take a reference which is a line of this editor. When you call display method with a line instance, this reference is contained in the caller. When you call display method with an editor instance, you have to set the line in a mandatory parameter.


This method does not accept any parameter.

In list context, it returns 'display' instances (that is Text::Editor::Easy::Display object(s)) or an empty list if the line is not visible. If wrap mode is not used, there can't be more than one 'display' instance associated to one 'line' instance. With wrap mode, it depends on the line size and on the screen width.

Called in scalar context, you just get the number of 'display' instances associated with that line : 0 if the 'line' is not visible, 1 or more if the line is visible.

Note that if wrap mode is used and the 'line' is partially visible (some 'displays' are visible, other are not) the result you get is identical as if the line was entirely visible. Lines are always displayed as a whole.


This method does not accept any parameter.

Returns the next 'line' instance or undef if it's the last.

    # A very slow slurp implementation (at present, 'editor' slurp method is written like that !)
    my $line   = $editor->first; # shortcut for $editor->number(1)
    my $slurp = $line->text;
    $line = $line->next;
    while ( $line ) {
        $slurp .= "\n" . $line->text;
        $line = $line->next;


This method does not accept any parameter.

Returns the order of the line (it's number). Note that for a given 'line' instance, this number will change according to updates ('line' creations or suppressions).


This method does not accept any parameter.

Returns the previous 'line' instance or undef if it's the first.


The interface of this method will change. At present, it's not possible to select lines that are not visible unless you force them to be visible.


This method accepts one parameter : a string that will update the 'line' content.

It returns the 'line' instance that was used to call the set.


This method does not accept any parameter.

It returns the text of the line.


This method does not accept any parameter.

It returns undef if the line is not displayed. When displayed, it returns the ordinate of the top of the line. See also "bottom_ord".


These methods shouldn't be used.

count (class method)

Number of "line" objects created for the thread, for all "editor" objects defined. As threre are more threads, there can be other "line" objects declared in other threads (and, why not, pointing at same the lines).

linesize (class method)

For debugging memory leaks which are numerous...



This is the only common value (it's an auto-incrementing integer chosen by 'File_manager' thread) between all threads : for a given 'editor' instance, if 2 lines (belonging to the same editor) have the same 'ref' in 2 different threads, they are pointing at the same line. But of course, as each thread has its own memory, scalar references and, then, line instances are different.


Returns the 'editor' instance the line belongs to. Should be useless (?).


Give the start position of the line in the file, 0 if there's no file associated. This position is true only at the beginning or just after a save. Positions are not updated at each change.


To save data in association to a particular line. This data is saved in the 'File_manager' thread, so it can be seen and shared by all threads thanks to 'get_info' method.


Retrieve 'info' associated to the 'line' object thanks to 'set_info' method.


Copyright 2008 - 2009 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.

syntax highlighting: