(クラス)
Span buffer
説明
An alternative to
StringBuf optimized for normal text edit operations: insertions and deletions that occur mostly near each other.
In addition to fast insertion and deletion, this class also supports recursive partitioning of the buffer into child
SpanBuf objects, which share the same character memory.
Operations that overwrite characters are implemented using insertion and deletion and are therefore more expensive than in a regular
StringBuf. These include the following:
This data structure is also sometimes referred to as a "piece table".
オーバーライド
Subclasses should provide the following constructors and overridden methods:
Most other methods are not overridable.
Here is a minimal example:
{define-class public MySpanBuf {inherits SpanBuf}
{constructor public {default
efficient-size:int = 0,
url:#Url = null,
...:any
}
{construct-super.default
efficient-size = efficient-size,
url = url,
...
}
}
{constructor protected {clone-from
other:MySpanBuf,
state:#SpanBufState = null
}
{construct-super.clone-from other, state = state}
}
{method public {clone}:MySpanBuf
{return {MySpanBuf.clone-from self}}
}
{method protected {clone-with-state state:SpanBufState}:MySpanBuf
{return {MySpanBuf.clone-from self, state = state}}
}
{constructor protected {construct-child parent:SpanBuf}
{construct-super.construct-child parent}
}
{method protected {create-child
prev:#SpanBuf, next:#SpanBuf
}:MySpanBuf
{return {MySpanBuf.construct-child self}}
}
}
コンストラクタ protected | {SpanBuf.clone-from} |
コンストラクタ protected | {SpanBuf.construct-child parent:SpanBuf} |
default: | Construct a new root SpanBuf. |
コンストラクタ public | {SpanBuf.default} |
appendable?: | Specifies whether parent span can append to this span. |
フィールド public SpanBuf.appendable?:
bool
アクセサ public final inline SpanBuf.attributes-observed?:
bool
アクセサ public final inline SpanBuf.auto-consolidate-threshold:
double セッター public final inline SpanBuf.auto-consolidate-threshold:
double
フィールド public-get private-set SpanBuf.change-counter:
uint
アクセサ public final inline SpanBuf.childless?:
bool
アクセサ public SpanBuf.defer-notification?:
bool セッター public SpanBuf.defer-notification?:
bool
フィールド public SpanBuf.directly-mutable?:
bool
アクセサ public final SpanBuf.efficient-size:
int セッター public final SpanBuf.efficient-size:
int
アクセサ public final inline SpanBuf.first-child:#
SpanBuf
アクセサ public final inline SpanBuf.last-child:#
SpanBuf
next: | Next sibling subbuffer. |
アクセサ public final SpanBuf.next:#
SpanBuf
アクセサ public final SpanBuf.non-blocking-supported?:
bool
observed?: | Indicate whether buffer has any observers. |
アクセサ public final inline SpanBuf.observed?:
bool
observers: | A linked list of observers of this buffer. |
open?: | Indiciate if stream is open. |
アクセサ public final SpanBuf.open?:
bool
アクセサ public final SpanBuf.origin-url:#
Url
orphaned?: | Whether this buffer was deleted from its parent. |
フィールド public SpanBuf.orphaned?:
bool
prependable?: | Specifies whether parent span can prepend to this span. |
フィールド public SpanBuf.prependable?:
bool
prev: | Previous sibling subbuffer. |
アクセサ public final SpanBuf.prev:#
SpanBuf
root: | Root SpanBuf for this buffer. |
アクセサ public final inline SpanBuf.root:
SpanBuf
アクセサ protected inline SpanBuf.shared-state:
any セッター protected inline SpanBuf.shared-state:
any
アクセサ public final inline SpanBuf.size:
int セッター public final SpanBuf.size:
int
url: | URL associated with buffer. |
アクセサ public inline SpanBuf.url:#
Url セッター public inline SpanBuf.url:#
Url
アクセサ public final SpanBuf.write-buffer-data-size:
int
アクセサ public final SpanBuf.write-buffer-size:
int
public final | {SpanBuf.clear}:void |
public | {SpanBuf.clear-observers}:void |
clone: | Returns a deep clone of this buffer. |
close: | Close output stream |
public final | {SpanBuf.close}:void |
public final | {SpanBuf.consolidate}:void |
dynamic-substr: | Returns substring that reflects changes in the underlying buffer. |
flush: | Flush output stream. |
public final | {SpanBuf.flush non-blocking?:bool = false,allow-short-write?:bool = false }:void |
public final inline | {SpanBuf.get i:int}:char |
public | {SpanBuf.get-buffer-containing offset:int,length:int = 1,max-depth:int = max-int }:(SpanBuf, offset-in-buf:int) |
get-column: | Compute the column of given location in the buffer. |
public final inline | {SpanBuf.get-column offset:int}:int |
get-line: | Reads line of text with same attributes starting at offset. |
public final | {SpanBuf.get-line}:(uint8, StringBuf) |
public final | {SpanBuf.get-next-attribute}:(new-offset:int, new-attr:uint8) |
public final | {SpanBuf.get-with-attributes i:int}:(char, uint8) |
protected | {SpanBuf.handle-transfer-to}:void |
public | {SpanBuf.line-column-to-location line:int, column:int}:int |
public | {SpanBuf.location-to-line-column offset:int}:(int, int) |
public | {SpanBuf.merge-with-next}:void |
public | {SpanBuf.object-describe}:void |
public | {SpanBuf.object-describe-for-debugging}:void |
observed-by?: | Indicate whether observer is attached to this buffer. |
public final | {SpanBuf.remove i:int,length:int = 1,error-if-missing?:bool = true }:void |
public final | {SpanBuf.remove-partitions}:void |
public final | {SpanBuf.replace}:void |
public final | {SpanBuf.set-attributes}:void |
public final | {SpanBuf.set-root-line-column line:int, column:int}:void |
public final | {SpanBuf.to-String}:String |
public final | {SpanBuf.write-one c:char}:void |
public final | {SpanBuf.write-one-string}:int |
メソッド 継承 StringInterface:
compare, equal?, find, find-char-class, find-string, prefix?, replace-clone, split, substr, suffix?, tail, to-double, to-InputStream, to-int, to-int64, to-lower-clone, to-upper-clone, trim-clone, trim-left-clone, trim-right-clone
(コンストラクタ)
protected | {SpanBuf.clone-from} |
Constructs a clone of another SpanBuf.
プログラミング注意事項
This should not be invoked directly.
オーバーライド
Subclasses should implement a similar constructor that invokes this one and which will be used by the subclass's version of
clone-with-state.
See
SpanBuf for an example.
(コンストラクタ)
protected | {SpanBuf.construct-child parent:SpanBuf} |
Construct a SpanBuf as a child of another.
オーバーライド
Subclasses should implement a similar constructor which invokes this one. This is only intended for use in implementing the
SpanBuf.create-child method.
See
SpanBuf for an example.
(コンストラクタ)
Construct a new root SpanBuf.
url: is assigned to the corresponding
url attribute.
...: arguments are converted to strings and concatenated to the buffer.
説明
(フィールド)
public SpanBuf.appendable?:
bool Specifies whether parent span can append to this span.
説明
When true, an insertion in the parent span corresponding to the end of this span can be appended to this span. Otherwise, the parent must prepend to the following span or create a new intermediate span. Note that this only applies to insertions through the parent, not those made directly on this object.
(アクセサ)
アクセサ public final inline SpanBuf.attributes-observed?:
bool Indicates whether attribute changes are observed.
説明
(アクセサ)
アクセサ public final inline SpanBuf.auto-consolidate-threshold:
double セッター public final inline SpanBuf.auto-consolidate-threshold:
double Threshold for automatic consolidation
説明
A number between 0 and 1 specifying the lower limit of the the percentage of memory that would remain after a a
consolidate operation, for consolidation to be done automatically when more memory is needed.
This may not be set above 95%. Default value is 70%.
(フィールド)
public-get private-set SpanBuf.change-counter:
uint Tracks changes to the buffer
説明
This value is initially set to 0 and will increase (not necessarily by one) every time a change is made to the buffer or any subbuffer contained in it. Only changes to the character contents of the buffer will increment the change counter. Adding or removing partitions should not affect the counter.
(アクセサ)
アクセサ public final inline SpanBuf.childless?:
bool Indicates whether buffer has children
説明
When true, the buffer has not been partitioned into child buffers and
first-child and
last-child will be null.
(アクセサ)
アクセサ public SpanBuf.defer-notification?:
bool セッター public SpanBuf.defer-notification?:
bool Whether to defer notification of observers.
説明
While true, observers will not be notified of changes. Setting this to false will dispatch any pending notifications.
(フィールド)
public SpanBuf.directly-mutable?:
bool Indicates whether buffer can be mutated by direct call.
説明
If this is false, then directly calling a method that mutates characters (.e.g,
remove or
splice) will throw an error. Operations that modify how the buffer is partitioned into subsidiary buffers are not affected by this setting. The contents of the buffer may still be changed through a parent buffer that is directly mutable.
By default the root
SpanBuf is directly mutable, but its children are not.
(アクセサ)
アクセサ public final SpanBuf.efficient-size:
int セッター public final SpanBuf.efficient-size:
int self の efficient-size を取得または設定します。
説明
efficient-size は、
WritableString またはサブクラスを拡張可能であり、かつ
処理効率を維持できる
上限サイズです。このアクセッサは実装ごとに定義されますが、一般に下位のデータ構造のサイズを反映します。割り当てサイズを超えて拡張する場合、下位のデータ構造を新しく割り当て、古いデータ構造からデータをコピーする必要があります。ただし、この処理は
非効率
であると見なされます。
requested-size: requested-size はシステムによって評価され、場合によっては変更されます。変更後の efficient-size を取得するには、ゲッターを使います。変更後の efficient-size は必ず requested-size 以上の大きさになります。
注意事項
efficient-size アクセッサの既定の実装はセッターを無視します。また、ゲッターは、すべてのサイズ変更処理が同程度に効率的であることを示す max-int を返します。
(アクセサ)
アクセサ public final inline SpanBuf.first-child:#
SpanBuf First child buffer
説明
If this buffer has been partitioned into subbuffers, this will refer to the first such buffer. Otherwise, this will be null.
Also see
SpanBuf.partition-at.
(アクセサ)
アクセサ public final inline SpanBuf.last-child:#
SpanBuf Last child buffer
説明
If this buffer has been partitioned into subbuffers, this will refer to the last such buffer. Otherwise, this will be null.
Also see
SpanBuf.partition-at.
(アクセサ)
アクセサ public final SpanBuf.next:#
SpanBuf Next sibling subbuffer.
説明
If this buffer is a subbuffer of another buffer, this will point to the sibling buffer immediately following this one.
This will be null if this is this is the last buffer within the
parent buffer or if this buffer has no parent.
(アクセサ)
アクセサ public final SpanBuf.non-blocking-supported?:
bool
(アクセサ)
アクセサ public final inline SpanBuf.observed?:
bool Indicate whether buffer has any observers.
説明
(フィールド)
A linked list of observers of this buffer.
説明
Any observers in this list will recieve notifications for major buffer operations. See
SpanBufObserver for details.
Also see:
(アクセサ)
アクセサ public final SpanBuf.open?:
bool Indiciate if stream is open.
説明
This is always true for this class.
(アクセサ)
アクセサ public final SpanBuf.origin-url:#
Url URL associated with buffer.
説明
(フィールド)
public SpanBuf.orphaned?:
bool Whether this buffer was deleted from its parent.
説明
(フィールド)
public SpanBuf.prependable?:
bool Specifies whether parent span can prepend to this span.
説明
When true, an insertion in the parent span corresponding to the beginning of this span can be prepended to this span. Otherwise, the parent must append to the following span or create a new intermediate span. Note that this only applies to insertions through the parent, not those made directly on this object.
(アクセサ)
アクセサ public final SpanBuf.prev:#
SpanBuf Previous sibling subbuffer.
説明
If this buffer is a subbuffer of another buffer, this will point to the sibling buffer immediately preceding this one.
This will be null if this is this is the first buffer within the
parent buffer or if this buffer has no parent.
(アクセサ)
アクセサ public final inline SpanBuf.root:
SpanBuf Root SpanBuf for this buffer.
説明
Returns the topmost SpanBuf containing this buffer.
(アクセサ)
SHA-1-Digest of root contents.
説明
Returns an SHA-1 digest of the contents of the
root buffer. The value is computed on demand and is cached until the buffer changes.
Note that setting the digest explicitly does not check to make sure that the digest actually matches the content.
(アクセサ)
アクセサ protected inline SpanBuf.shared-state:
any セッター protected inline SpanBuf.shared-state:
any State shared by root buffer and its subbuffers
説明
This holds state shared by the
root buffer and all of its subsidiary buffers for use by subclasses. By default this is null. State is not copied by cloning operations but is retained when buffer is deleted.
(アクセサ)
アクセサ public final inline SpanBuf.size:
int セッター public final SpanBuf.size:
int self 内の文字数。
戻り値
文字数を示す int 値。
説明
読み取り専用文字列の場合
書き込み可能文字列の場合
- 文字列内の文字数を返します。
- 文字列内の文字数を設定できます。
size をその文字列の現在のサイズよりも小さい値に設定した場合、その文字列は切り詰められます。
size を現在のサイズよりも大きい値に設定した場合、差分の文字数がその文字列の末尾に追加されます。この場合、追加される文字の値は Unicode 値の
0000 になります。
例
次の例は、読み取り専用文字列に対して
size を使用した場合です。
例 |
|
{value
|| Declare and initialize a read-only string
let s:String = "Hello World!"
|| Output a message that includes the return value of
|| a call to "size".
|| Note that you must use "value" to display the value
|| of "s.size", rather than the text "s.size".
{text There are {value s.size} characters in the string.}
}
| |
次の例は、書き込み可能文字列に対して
size を使用した場合です。
例 |
|
{value
|| Declare and initialize a writable string.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Set the size of the string to 5 characters.
|| The string should now contain only the first five
|| characters, "Hello".
set sb.size = 5
|| Output a message that includes the new string
{text If {monospace size} is set to 5, the string
becomes: {value sb}}
}
| |
例 |
|
{value
|| Declare and initialize a writable string.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Set the size of the string to 20 characters.
|| The string should now have 8 characters
|| with the Unicode value 0000 at the end.
set sb.size = 20
|| Output a message that includes the new string.
{text Then, if {monospace size} is set to 20, the string
becomes: {value sb}}
}
| |
注意事項
(アクセサ)
アクセサ public inline SpanBuf.url:#
Url セッター public inline SpanBuf.url:#
Url URL associated with buffer.
説明
This is returned by
origin-url.
Typically this will be the URL of the file from which the buffers contents were read.
(アクセサ)
アクセサ public final SpanBuf.write-buffer-data-size:
int バッファ内のフラッシュされていないデータ量を示します。
(アクセサ)
アクセサ public final SpanBuf.write-buffer-size:
int
(メソッド)
Add an observer for this buffer.
説明
Adds a
SpanBufObserver for this buffer. Observer will be added to the end of the
observers list.
Does nothing if
observer is already attached to this buffer.
(メソッド)
public final | {SpanBuf.clear}:void |
self をクリアします。
説明
self の内容を空の文字列に置き換えます。
例
例 |
|
{value
|| Declare and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Clear the StringBuf.
{sb.clear}
|| Check if the StringBuf is empty.
{text The assertion that the string is empty
is... {value sb.empty?}}
}
| |
(メソッド)
public | {SpanBuf.clear-observers}:void |
Remove all observers from this buffer.
(メソッド)
Returns a deep clone of this buffer.
(メソッド)
Internal method for cloning SpanBuf.
プログラミング注意事項
This method should not be invoked directly.
説明
This should be overridden by subclasses to return a clone of this object using the subclass's version of
SpanBuf.clone-from with the provided
state value.
See
SpanBuf for an example.
(メソッド)
public final | {SpanBuf.close}:void |
Close output stream
説明
This does nothing in this class.
(メソッド)
StringInterface を self に連結します。
説明
str を self の末尾に追加します。
例
例 |
|
{value
|| Declare and initialize two StringBufs.
let sb1:StringBuf = {StringBuf "Hello World!"}
let sb2:StringBuf = {StringBuf " Can you hear me?"}
|| Concatenate "sb2" onto "sb1".
{sb1.concat sb2}
|| Display the resulting StringBuf.
{value sb1}
}
| |
(メソッド)
public final | {SpanBuf.consolidate}:void |
Consolidates memory used by buffer.
説明
This reclaims unused memory allocated by the buffer. It does not otherwise affect the state of the buffer.
(メソッド)
Return a new child SpanBuf.
プログラミング注意事項
This method should not be invoked directly.
オーバーライド
Subclasses should implement this method to return a new instance constructed using the subclass's version of
SpanBuf.construct-child. The overridden version should not be public.
The
prev and
next arguments are the sibling buffers that will be before and after this buffer once it is linked in by the caller.
If this is not overridden in a subclass, then any child buffers created using
partition-at and the like will be of type
SpanBuf, not the subclass type.
See
SpanBuf for an example.
(メソッド)
Returns substring that reflects changes in the underlying buffer.
説明
Returns a
SafeSubString representing the substring of this buffer starting at offset
start and with given
length.
Unlike
StringInterface.substr, which returns an immutable
String, and which therefore will not reflect changes to the buffer, this will return an object that reflects changes to the buffer after the substring is returned. This means that the size of the returned substring may become shorter if this buffer becomes shorter.
(メソッド)
public final | {SpanBuf.flush non-blocking?:bool = false,allow-short-write?:bool = false }:void |
Flush output stream.
説明
This does nothing in this class.
(メソッド)
public final inline | {SpanBuf.get i:int}:char |
self 内の指定された文字を返します。
index: 取得する文字の位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0 ~ (self.size - 1) の範囲です (0 と (self.size - 1) を含む)。
例
例 |
|
{value
|| Declare and initialize a string.
let s:String = "Hello World!"
|| Display the string and return the
|| character at position 7.
|| Remember that the leftmost position
|| is 0 (zero).
{text {value s}
{br}The character at position 7 is {s.get 7}.}
}
| |
注意事項
(メソッド)
Returns an array describing the attributes in a given range.
説明
Returns an array of
SpanBufAttributes describing what attributes are set in the range starting at
offset and continuing for
length characters.
The attributes will be appended to
out, if non-null.
(メソッド)
public | {SpanBuf.get-buffer-containing offset:int,length:int = 1,max-depth:int = max-int }:(SpanBuf, offset-in-buf:int) |
Find subbuffer containing given range.
offset: is an offset within the range of this buffer, i.e. a value between 0 and
size.
length: is the length of the range.
max-depth: is the maximum depth to recurse. By default, the lowest level subbuffer will be found. Setting this to one will ensure that only immediate children or the buffer itself may be returned. Setting this to zero will result in this buffer being returned.
戻り値
Returns the innermost buffer upto max-depth that contains all of the characters beginning at offset and ending at offset + length - 1.
(メソッド)
public final inline | {SpanBuf.get-column offset:int}:int |
Compute the column of given location in the buffer.
説明
(メソッド)
public final | {SpanBuf.get-line}:(uint8, StringBuf) |
Reads line of text with same attributes starting at offset.
説明
Writes into
out, characters from this buffer starting at
offset until a newline sequence is encountered or the attributes associated with the next character differs from the last one written. The terminating newline sequence characters will be written as long as their attributes match the rest of the text.
The attributes value will default to zero if not set using
set-attributes. The meaning of the attributes value is user defined.
Returns the attributes value associated with the characters and the
out variable.
(メソッド)
public final | {SpanBuf.get-next-attribute}:(new-offset:int, new-attr:uint8) |
Find next offset at which attribute changes.
説明
Finds the next offset starting with
offset below
end at which the associated attribute value
new-attr differs from
attr after the given
mask has been applied to it. That is, finds first offset at which
{bit-and mask, new-attr} != attris true. Returns the offset and the new (unmasked) attribute value. If no differing attribute is found within the specified range, this will return
end and
attr (which is not necessarily the actual attribute value associated with
end).
It is assumed that
{bit-and mask, attr} is equal to
attr. Note that the meaning of
mask is different from that used by
set-attributes.
Also see
SpanBuf.get-with-attributes and
SpanBuf.get-line.
(メソッド)
public final | {SpanBuf.get-with-attributes i:int}:(char, uint8) |
Gets character and associated attributes at given offset.
説明
Returns the character and its associated attributes value for the given offset
i. The attributes value will default to zero if not set using
set-attributes.
The meaning of the the attributes value is user defined.
(メソッド)
protected | {SpanBuf.handle-transfer-to}:void |
Allows subclasses to respond to merge/split operations.
説明
This is invoked when merging or splitting child buffers to indicate that the contents of this buffer from from-offset to the end of the buffer is being transfered to other at to-offset. When contents are being removed this will be invoked with other set to null.
オーバーライド
Subclasses may override this method in order to transfer associated state to other.
(メソッド)
文字を self に挿入します。
c: 挿入する文字。
index: 文字を挿入する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0 ~ self.size の範囲です (0 と self.size を含む)。
説明
位置 index より後ろにあるすべての文字を 1 つずつ後ろにずらし、位置 index に文字 c を挿入します。
例
例 |
|
{value
|| Declare and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Insert a comma (,) at position 5.
|| Remember that the leftmost position
|| is 0 (zero).
{sb.insert ',', 5}
|| Display the resulting StringBuf.
{value sb}
}
| |
注意事項
(メソッド)
public | {SpanBuf.line-column-to-location line:int, column:int}:int |
Converts line and column to buffer offset.
説明
Returns offset in this buffer corresponding to given line and column. The line and column are computed with respect to the
root buffer.
This will return a value outside of the range of this buffer (i.e. either less than zero or greater than the size of the buffer) if
line and
column refer to a location outside the buffer.
(メソッド)
public | {SpanBuf.location-to-line-column offset:int}:(int, int) |
Converts offset to line and column.
説明
The line and column are computed with respect to the
root buffer.
Columns are indexed from 0, while lines are indexed from 1; .e.g, the first position in the file is line 1, column 0.
(メソッド)
public | {SpanBuf.merge-with-next}:void |
Merges next buffer into this one.
説明
Merges the
next sibling buffer, if any, into this buffer. This buffer's
appendable? attribute will be set to that of the
next buffer.
If
next is null, this will do nothing.
(メソッド)
public | {SpanBuf.object-describe}:void |
ユーザーが印刷するのに適した方法でオブジェクトを記述します。
out: 文字が送られるストリーム。
locale:
self の表示方法をコントロールする
Locale。
説明
このメソッドは、一般に、
"%s" フォーマット キーを使用して間接的に起動されます。
上記の表現は単純に以下を呼び出します。
{obj.object-describe out}
たとえば、
u が
Url である場合を考えます。
{u.object-describe os}
上記の表現により、
u の名前が
os に書き込まれます。
このメソッドの既定の実装では、以下を呼び出す効果があります。
{format
out = out, locale = locale,
"%v", obj
}
("%v" フォーマット キーの詳細については、
format を参照してください)。
(メソッド)
public | {SpanBuf.object-describe-for-debugging}:void |
オブジェクトについて細部を記述します。これは主にデバッグ目的での使用が想定されています。
out: 文字が送られるストリーム。
locale:
self の表示方法をコントロールする
Locale。
説明
このメソッドは、一般に、"%y" フォーマット キーを使用して間接的に起動されます。"%y" フォーマット キーは、このメソッドによって生成された結果を、次のような何らかの型またはアドレス情報でラップします。
{do
let buf:StringBuf = {StringBuf}
{self.object-describe-for-debugging buf, {get-syntax-locale}}
{format out = out, "[<type> @<addr> %s]", buf}
}
このメソッドの既定の実装では
{format out = out, "%w", self} を呼び出します。
(「%w」フォーマット キーの詳細については、
format を参照してください)。
(メソッド)
Indicate whether observer is attached to this buffer.
説明
Return true if observer is currently attached to this buffer.
(メソッド)
Partition buffer into subbuffers
説明
Partitions the buffer at the specified
offset, which must be less than
size, and returns the child
SpanBuf beginning at that offset.
The child's
parent will be set to this object and its its
prev and
next accessors will refer to adjacent sibling
SpanBufs, if they exist.
This will do nothing if there is already a child
SpanBuf at the offset. If
offset is zero and the buffer currently has no child
SpanBufs, then this will create a single child including the entire contents of the buffer.
(メソッド)
public final | {SpanBuf.remove i:int,length:int = 1,error-if-missing?:bool = true }:void |
指定された文字を self から削除します。
index: 文字の削除を開始する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0 ~ self.size の範囲です (0 と self.size を含む)。
length: 削除する文字数。length の既定値は 1 です。length はキーワード引数です。length を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:length = 6)。
error-if-missing?:
存在しない文字を削除しようとしたときにこのメソッドがエラーを生成するかどうかを示す、ブール値のフラグ。位置 0 と self.size の間の文字を削除できます。
error-if-missing? を true に設定した場合、存在しない文字を削除しようとするとエラーがスローされます。エラーが発生するとプログラムの実行が停止し、エラー メッセージが表示されます。既定では、error-if-missing? は true です。error-if-missing? を false に設定した場合、エラーは生成されません。また、有効な範囲内にある文字は削除されますが、有効な範囲内にない文字は削除されず、削除後の文字列が返されます。
error-if-missing? はキーワード引数です。error-if-missing? を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:error-if-missing? = false)。
説明
self から length 個の文字を削除します。削除開始位置は index です。
例
例 |
|
{value
|| Declare and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Remove 6 characters, starting at
|| position 5.
|| Remember that the leftmost position
|| is 0 (zero).
{sb.remove 5, length = 6}
|| Display the resulting StringBuf.
{value sb}
}
| |
注意事項
(メソッド)
Remove observer from this buffer.
説明
Remove observer from the list of observers for this buffer.
Does nothing if observer is not currently attached to the buffer.
(メソッド)
public final | {SpanBuf.remove-partitions}:void |
Merges all subbuffers into one.
説明
Removes all subbuffers, returning content to the this buffer. After invoking this,
childless? will be true for the buffer.
This does not affect the underlying string contents.
(メソッド)
public final | {SpanBuf.replace}:void |
old の各オカレンスを new に置換します。
old: new で置換する部分文字列。
new: old の各オカレンスを置換する部分文字列。
説明
左から右に部分文字列 old を検索します。各オカレンスごとに、old を削除し、new をつなぎ合わせて、新規に挿入された文字の後から検索を再開します。
例
例 |
|
{value
|| Declare and initialize a string
let sb:StringBuf = {StringBuf "Silly willy"}
|| Replace each occurrence of "ill" with "ick".
{sb.replace "ill", "ick"}
|| Display the resulting StringBuf.
sb
}
| |
(メソッド)
self 内の文字を置換します。
index: 置換する文字の位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0 ~ (self.size - 1) の範囲です (0 と (self.size - 1) を含む)。
c: 新しい文字。
説明
位置 index にある文字を c に置換します。
例
例 |
|
{value
|| Declare and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Replace character 11 (!) with a period (.).
|| Remember that the leftmost position
|| is 0 (zero).
{sb.set 11, '.'}
|| Display the resulting StringBuf.
{value sb}
}
| |
注意事項
(メソッド)
public final | {SpanBuf.set-attributes}:void |
Sets attributes value for specified character range.
説明
Sets the attributes value associated with the characters starting at offset
start and ending just before offset
end. The attributes value is set by replacing the previous attributes value using the following logic:
{bit-or attributes,
{bit-and old-attributes, mask}
}
Setting the
mask to zero will cause the attributes in the specified range to be overwritten with the new value. You can use the mask to allocate bit fields within the attributes value.
The attributes values set by this method are available through
get-with-attributes and
get-line.
The meaning of the attributes value is user defined, but it is expected to be used to associate semantic tags to ranges of text which may be used in rendering. For instance, a bit could be used to indicate the presence of an error in a range of text, and a text renderer using the buffer can use the presence of the error bit to peform some kind of error highlighting for that range.
Both
start and
end will be normalized to fit within the current range of the buffer.
(メソッド)
self の内容を別の文字列の内容に置換します。
例
例 |
|
{value
|| Declare and initialize a StringBuf
let sb:StringBuf = {StringBuf "Hello World!"}
|| Replace the contents
{sb.set-contents {StringBuf "Here comes Curl!"}}
|| Display the StringBuf
{value sb}
}
| |
(メソッド)
public final | {SpanBuf.set-root-line-column line:int, column:int}:void |
Set the starting line and column of the root buffer.
説明
All line and column computations are computed relative to these numbers. Typically these values are set in the
default constructor and are usually set to their default values of 1 and 0.
(メソッド)
StringInterface を self に挿入します。
index:
StringInterface を挿入する位置。最左端の文字の位置は
0 です。最右端の文字の位置は
(self.size - 1) です。有効値は
0 ~
self.size の範囲です (
0 と
self.size を含む)。
説明
self 内の位置 index より後ろにある文字を str の文字数分後ろにずらし、位置 index に str を挿入します。
例
例 |
|
{value
|| Declare and initialize two StringBufs.
let sb1:StringBuf = {StringBuf "Hello World!"}
let sb2:StringBuf = {StringBuf ", can you hear me,"}
|| Insert "sb2" into "sb1" at position 5.
|| Remember that the leftmost position
|| is 0 (zero).
{sb1.splice sb2, 5}
|| Display the resulting StringBuf.
{value sb1}
}
| |
(メソッド)
Splits buffer at offset
説明
Splits this buffer into two adjacent buffers and returns the latter buffer.
If the buffer has no parent, then this is the same as
partition-at.
(メソッド)
Produces a source location for given subrange of buffer.
説明
By default produces location corresponding to the entire buffer.
(メソッド)
public final | {SpanBuf.to-String}:String |
self と同一 (==) の String を作成します。
戻り値
例
例 |
|
{value
|| Define and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Convert the StringBuf to a String.
let s:String = {sb.to-String}
|| Display the contents of the String.
{value s}
}
| |
(メソッド)
public final | {SpanBuf.write-one c:char}:void |
Writes character to output stream.
説明
(メソッド)
public final | {SpanBuf.write-one-string}:int |
Writes a string of characters to output stream.
説明
Appends characters from str to end of this buffer, beginning with start and with length specified by length.