ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 6日 (木) 12:56:14 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-txtw-itrsmrks ------------------------- @@ -22,7 +22,7 @@ Sometimes you would like to refer to a position within a text buffer by means of index and offset, which in the early days of programming, before multi-byte characters were introduced, used to be the rather natural way to navigate the buffer. If you wish you can still navigate text buffer this way, though in the case you use UTF-8 character encoding, this can become increasingly unreliable. Should you have a need to do so, you can employ Gtk::TextBuffer#get_iter_at_offset(char_offset), which gets an iterator pointing to((*char_offset*))within the text buffer, and Gtk::TextIter#offset which returns the character offset of an iterator (note in both cases we mean character offset, not byte offset). -There is another method, which for measuring distance from the beginning of a line (note, the beginning of a line, not the beginning of the text buffer) does not count characters, and for which the offset does not necessarily start at the beginning of the text buffer, but instead at a particular line. It is: Gtk::TextBuffer#get_iter_at_line_index(line_number, byte_index). This method obtains an iterator pointing to byte_index within the given line.((*byte_index*))must point at the start of a UTF-8 character, and must not be beyond the end of the line. Note bytes, not characters; UTF-8 may encode one character as multiple bytes. +There is another method, which for measuring distance from the beginning of a line (note, the beginning of a line, not the beginning of the text buffer) does not count characters, and for which the offset does not necessarily start at the beginning of the text buffer, but instead at the beginning of a particular line. It is: Gtk::TextBuffer#get_iter_at_line_index(line_number, byte_index). This method obtains an iterator pointing to byte_index within the given line.((*byte_index*))must point at the start of a UTF-8 character, and must not be beyond the end of the line. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.