Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file subText.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164# 1 "Camomile/public/subText.ml"(** Sub-texts, parts of original (ur-) texts.
The signature and semantics matches those of UStorage. *)(* Copyright (C) 2002, 2003 Yamagata Yoriyuki. distributed with LGPL *)(* This library is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Lesser General Public License *)(* as published by the Free Software Foundation; either version 2 of *)(* the License, or (at your option) any later version. *)(* As a special exception to the GNU Library General Public License, you *)(* may link, statically or dynamically, a "work that uses this library" *)(* with a publicly distributed version of this library to produce an *)(* executable file containing portions of this library, and distribute *)(* that executable file under terms of your choice, without any of the *)(* additional requirements listed in clause 6 of the GNU Library General *)(* Public License. By "a publicly distributed version of this library", *)(* we mean either the unmodified Library as distributed by the authors, *)(* or a modified version of this library that is distributed under the *)(* conditions defined in clause 3 of the GNU Library General Public *)(* License. This exception does not however invalidate any other reasons *)(* why the executable file might be covered by the GNU Library General *)(* Public License . *)(* 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 the GNU *)(* Lesser General Public License for more details. *)(* You should have received a copy of the GNU Lesser General Public *)(* License along with this library; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)(* USA *)(* You can contact the authour by sending email to *)(* yoriyuki.y@gmail.com *)moduletypeType=sigtypetvalget:t->int->UChar.tvalinit:int->(int->UChar.t)->tvallength:t->inttypeindexvallook:t->index->UChar.tvalnth:t->int->indexvalfirst:t->indexvallast:t->indexvalnext:t->index->indexvalprev:t->index->indexvalmove:t->index->int->indexvalout_of_range:t->index->boolvalcompare_index:t->index->index->intvaliter:(UChar.t->unit)->t->unitvalcompare:t->t->intmoduleBuf:sigtypebufvalcreate:int->bufvalcontents:buf->tvalclear:buf->unitvalreset:buf->unitvaladd_char:buf->UChar.t->unitvaladd_string:buf->t->unitvaladd_buffer:buf->buf->unitendtypeur_texttypeur_indexvalrefer:ur_text->ur_index->ur_index->tvalexcerpt:t->ur_textvalcontext:t->ur_text*ur_index*ur_indexvalur_index_of:t->index->ur_indexendmoduleMake(Text:UnicodeString.Type)=structtypet=Text.t*Text.index*Text.indextypeindex=Text.indexletout_of_range(t,i0,j)i=ifText.compare_indexti0i>0thentrueelseifText.compare_indextij>=0thentrueelseText.out_of_rangetiletlook((t,_,_)ass)i=ifout_of_rangesithenfailwith"SubText.look"elseText.looktiletnext(t,_,_)i=Text.nexttiletprev(t,_,_)i=Text.prevtiletmove(t,_,_)in=Text.movetinletnth((_,i,_)ass)n=movesinletfirst(_,i,_)=iletlast(t,_,i)=Text.prevtiletcompare_index(t,_,_)ij=Text.compare_indextijletgetsn=looks(nthsn)letinitlenf=lett=Text.initlenfin(t,Text.ntht0,Text.nextt(Text.lastt))letlength(t,i,j)=letrecloopin=ifText.compare_indextij>=0thennelseloop(Text.nextti)(n+1)inloopi0letiterproc(t,i,j)=letrecloopi=ifText.compare_indextij>=0then()elsebeginproc(Text.lookti);loop(Text.nextti)endinloopiletcompare(t1,i1,j1)(t2,i2,j2)=letrecloopi1i2=ifText.compare_indext1i1j1>=0thenifText.compare_indext2i2j2>=0then0else~-1elseifText.compare_indext2i2j2>=0then1elseletsgn=UChar.compare(Text.lookt1i1)(Text.lookt2i2)inifsgn=0thenloop(Text.nextt1i1)(Text.nextt2i2)elsesgninloopi1i2moduleBuf=structincludeText.Bufletadd_stringbufs=iter(add_charbuf)sletcontentsbuf=lett=Text.Buf.contentsbufin(t,Text.ntht0,Text.nextt(Text.lastt))endtypeur_text=Text.ttypeur_index=Text.indexletrefertij=(t,i,j)letexcerpts=letbuf=Buf.create0inBuf.add_stringbufs;Text.Buf.contentsbufletcontexts=sletur_index_of_i=iend