Thread Scrolled Text auslesen (5 answers)
Opened by Kean at 2004-08-18 15:34

Crian
 2004-08-18 16:16
#42492 #42492
User since
2003-08-04
5872 Artikel
ModeratorIn
[Homepage]
user image
Im Gegensatz etwa zum Entry, wo man mit get einfach den gesamten String bekommt, muss man beim Text-Widget angeben, welche Teile des Textes man möchte. Find ich eigentlich blöd, warum gibt man nicht einfach den gesamten Text zurück, wenn keine Aufrufparameter angegeben werden... Naja, ist nur eine Sache, die man wissen mus. =)

'1.0' bedeutet Zeile 1 Zeichen 0 (also b dem ersten Zeichen)
'end' bedeutet ganz hinten

Ein Tipp: Mit perldoc kannst Du Dir auf der Kommandozeile gezielt Infos zu bestimmten Widgets holen, schneller als jedes Nachschlagen im Buch, etwa perldoc Tk::Text. Wenn man dort dann etwa naach get sucht, findet man diesen Abschnitt:

Quote
   *$text*->get(*index1, *?*index2*?)
       Return a range of characters from the text. The return value will be
       all the characters in the text starting with the one whose index is
       *index1* and ending just before the one whose index is *index2* (the
       character at *index2* will not be returned). If *index2* is omitted
       then the single character at *index1* is returned. If there are no
       characters in the specified range (e.g. *index1* is past the end of
       the file or *index2* is less than or equal to *index1*) then an
       empty string is returned. If the specified range contains embedded
       windows, no information about them is included in the returned
       string.


edit renee: es muss perldoc statt erldoc heißen ;)
Was hatte ich denn geschrieben? Ach erldoc *rofl* Danke =)

An anderer Stelle in der Datei heißt es dann

Quote
INDICES
   Many of the methods for texts take one or more indices as arguments. An
   index is a string used to indicate a particular place within a text,
   such as a place to insert characters or one endpoint of a range of
   characters to delete. Indices have the syntax

    base modifier modifier modifier ...

   Where *base* gives a starting point and the *modifier*s adjust the index
   from the starting point (e.g. move forward or backward one character).
   Every index must contain a *base*, but the *modifier*s are optional.

   The *base* for an index must have one of the following forms:

   *line*.*char*
       Indicates *char*'th character on line *line*. Lines are numbered
       from 1
for consistency with other UNIX programs that use this
       numbering scheme. Within a line, characters are numbered from 0. If
       *char* is end then it refers to the newline character that ends the
       line.

   @*x*,*y*
       Indicates the character that covers the pixel whose x and y
       coordinates within the text's window are *x* and *y*.

   end Indicates the end of the text (the character just after the last
       newline).

   *mark*
       Indicates the character just after the mark whose name is *mark*.

   *tag*.first
       Indicates the first character in the text that has been tagged with
       *tag*. This form generates an error if no characters are currently
       tagged with *tag*.

   *tag*.last
       Indicates the character just after the last one in the text that has
       been tagged with *tag*. This form generates an error if no
       characters are currently tagged with *tag*.

   *$widget*
       Indicates the position of the embedded window referenced by
       *$widget*. This form generates an error if *$widget* does not
       reference to an embedded window.

   *imageName*
       Indicates the position of the embedded image whose name is
       *imageName*. This form generates an error if there is no embedded
       image by the given name.

       If the *base* could match more than one of the above forms, such as
       a *mark* and *imageName* both having the same value, then the form
       earlier in the above list takes precedence. If modifiers follow the
       base index, each one of them must have one of the forms listed
       below. Keywords such as chars and wordend may be abbreviated as long
       as the abbreviation is unambiguous.

   + *count* chars
       Adjust the index forward by *count* characters, moving to later
       lines in the text if necessary. If there are fewer than *count*
       characters in the text after the current index, then set the index
       to the last character in the text. Spaces on either side of *count*
       are optional.

   - *count* chars
       Adjust the index backward by *count* characters, moving to earlier
       lines in the text if necessary. If there are fewer than *count*
       characters in the text before the current index, then set the index
       to the first character in the text. Spaces on either side of *count*
       are optional.

   + *count* lines
       Adjust the index forward by *count* lines, retaining the same
       character position within the line. If there are fewer than *count*
       lines after the line containing the current index, then set the
       index to refer to the same character position on the last line of
       the text. Then, if the line is not long enough to contain a
       character at the indicated character position, adjust the character
       position to refer to the last character of the line (the newline).
       Spaces on either side of *count* are optional.

   - *count* lines
       Adjust the index backward by *count* lines, retaining the same
       character position within the line. If there are fewer than *count*
       lines before the line containing the current index, then set the
       index to refer to the same character position on the first line of
       the text. Then, if the line is not long enough to contain a
       character at the indicated character position, adjust the character
       position to refer to the last character of the line (the newline).
       Spaces on either side of *count* are optional.

   linestart
       Adjust the index to refer to the first character on the line.

   lineend
       Adjust the index to refer to the last character on the line (the
       newline).

   wordstart
       Adjust the index to refer to the first character of the word
       containing the current index. A word consists of any number of
       adjacent characters that are letters, digits, or underscores, or a
       single character that is not one of these.

   wordend
       Adjust the index to refer to the character just after the last one
       of the word containing the current index. If the current index
       refers to the last character of the text then it is not modified.

       If more than one modifier is present then they are applied in
       left-to-right order. For example, the index ``end - 1 chars'' refers
       to the next-to-last character in the text and ``insert wordstart - 1
       c'' refers to the character just before the first one in the word
       containing the insertion cursor.



Dann weiß man wirklich so ungefähr alles ;-)\n\n

<!--EDIT|Crian|1092832729-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite

View full thread Scrolled Text auslesen