runes_cursor.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
class RUNES_CURSOR < $TEXT_CURSOR{RUNE,RUNES}
class RUNES_CURSOR < $TEXT_CURSOR{RUNE,RUNES} is
-- This class models a pointer referring to the successive elements of
-- a list/string. It provides a convenient mechanism to convert string
-- representations of other objects into objects of the appropriate classes.
-- If the expected objext representation was not found then the cursor error
-- state is set appropriately.
-- Version 1.0 Apr 99. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 14 Apr 99 kh Original for V8 of text classes
include TEXT_CURSOR{RUNE,RUNES} ;
reset_line(
val : CARD
)
pre ~void(self)
post line_no = val
is
-- This is provided for use when it has been necessary to change to
-- different positions in the string, using set_index. If track needs to be
-- kept of the line number then this routine enables restoration.
line_no := val
end ;
split(
ch : RUNE
) : FLIST{RUNES}
pre ~void(self)
and (buffer.size > 0)
post (~buffer.contains(ch)
and (result.size = 1)
and (result[0] = buffer))
or (result.size > 1)
is
-- This routine splits the string into a sequence of strings separated
-- at each occurrence of ch.
res : FLIST{RUNES} := FLIST{RUNES}::create ;
elt : RUNES := RUNES::create ;
loop
until!(is_done) ;
elt := get_upto_char(ch) ;
if (is_done) then
if elt.size > 0 then -- terminating non-empty segment!
res := res.push(elt)
end ;
break!
else
res := res.push(elt) ;
advance -- past the 'ch'
end
end ;
return res
end ;
current_loc_str(
cursor_char : RUNE
) : RUNES
pre ~void(self)
and (buffer.size > 0)
post (result[result.size - 1] = cursor_char)
is
-- This routine returns a string which is space-filled up to the
-- cursor_char which when printed/displayed therefore would appear at the
-- current location in the line.
loc_current : CARD := index ;
skip_back_to_line_start ;
cnt : CARD := loc_current - index ;
if index = 0 then
cnt := cnt - 1
end ;
set_index(loc_current) ;
return RUNES::create(buffer.index_lib.Space.rune).repeat(cnt) + cursor_char
end ;
end ; -- RUNES_CURSOR