「利用者:黄身」の版間の差分

提供: MeryWiki
ナビゲーションに移動 検索に移動
黄身 (トーク | 投稿記録)
編集の要約なし
黄身 (トーク | 投稿記録)
編集の要約なし
1行目: 1行目:
Ginnieから移行中。何か変な所があったらその癖が抜けてないせいです……
Ginnieから移行中。何か変な所があったらその癖が抜けてないせいです……
=覚え書き=
=覚え書き=
;include/StateBackup.js
:表示行頭がActive/Anchorになる様な範囲の場合、Restoreするとそれぞれ直前の表示行末に移動する。
:mePosLogicalをmePosViewに変えるといい。
;Document.GetLine
;Document.GetLine
:デフォルトでは表示行を取得。meGetLineLogicalが未定義なので0を指定する。
デフォルトでは表示行を取得。meGetLineLogicalが未定義なので0を指定する。
;最初の数
;最初の数
:行:1 (Document.GetLine)
*行:1 (Document.GetLine)
:文頭からの位置:0 (Selection.GetActivePos)
*文頭からの位置:0 (Selection.GetActivePos)
:桁:1 (Selection.GetActivePointX)
*桁:1 (Selection.GetActivePointX)
:Editor,Document:0 (Editors.Item.Documents.Item)
*Editor,Document:0 (Editors.Item.Documents.Item)
;Window.Document
;Window.Document
:Document.NewFile後も更新されない。
Document.NewFile後も更新されない。
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
Editor.ActiveDocument.NewFile();
Editor.ActiveDocument.NewFile();
18行目: 15行目:
</source>
</source>
;Editor.FindInFiles
;Editor.FindInFiles
:ディレクトリ名は最後を"\\"か"\\*"にする。
*ディレクトリ名は最後を"\\"か"\\*"にする。
:アクティブな文書が結果表示で乗っ取られる。
*アクティブな文書が結果表示で乗っ取られる。
;PopupMenu.Track
;PopupMenu.Track
:引数無しだとエラー。0でキャレット位置に表示。mePosMouseは1。
*引数無しだとエラー。0でキャレット位置に表示。mePosMouseは1。
:キャンセルした場合の返り値は0。
*キャンセルした場合の返り値は0。
:返り値を変数に入れるなりOutputするなりしないとメニューは表示されない。
*返り値を変数に入れるなりOutputするなりしないとメニューは表示されない。
:領域外をクリックしてキャンセルした場合、続けてTrackしていても実行されない。Escでだとされる。
*領域外をクリックしてキャンセルした場合、続けてTrackしていても実行されない。Escでだとされる。
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
var p=CreatePopupMenu();
var p=CreatePopupMenu();
34行目: 31行目:
</source>
</source>
;Selection.Replace
;Selection.Replace
:検索文字列が0x000aから始まるとき、meFindReplaceRegExpを指定しないと、meReplaceAllがおかしい。
検索文字列が0x000aから始まるとき、meFindReplaceRegExpを指定しないと、meReplaceAllがおかしい。
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
Selection.Replace("\n","",meReplaceAll); //最初の1つだけ処理される
Selection.Replace("\n","",meReplaceAll); //最初の1つだけ処理される
41行目: 38行目:
</source>
</source>
;Document.Text
;Document.Text
:代入する場合、設定上の改行コードがCRLFでも、改行記号は文字列中の改行によって変わる。
代入する場合、設定上の改行コードがCRLFでも、改行記号は文字列中の改行によって変わる。
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
$d.Text=$d.Text //改行記号はLFになる
$d.Text=$d.Text //改行記号はLFになる
</source>
</source>
;include/StateBackup.js
表示行頭がActive/Anchorになる様な範囲の場合、Restoreするとそれぞれ直前の表示行末に移動する。<br />
mePosLogicalをmePosViewに変えるといい。


=KILI.js=
=KILI.js=
50行目: 50行目:
(これ以外のファイルでも)引数のコメントで「*」が付いてるものは既定値。
(これ以外のファイルでも)引数のコメントで「*」が付いてるものは既定値。
;よく出てくる変数名
;よく出てくる変数名
:$d:対象となる文書のDocument。
*$d:対象となる文書のDocument。
:$s:対象となる文書のSelection。
*$s:対象となる文書のSelection。
:SB:StateBackup。
*SB:StateBackup。
;対象とするDocument/Selection
==$d==
:$d/$s→defaultDocument/Selection→アクティブの順で使用。
ほぼ全てのメソッドは最後の引数に「$d」を取る。これが指定されていない場合はアクティブな文書を対象とする。
;clearDefault
==オブジェクト==
:既定をクリア
;Point
<source lang="javascript" style="word-wrap:break-word;">
座標を表すオブジェクト。今のところx,yが含まれているだけ。
function clearDefault()
</source>
;getDocument
:既定のDocumentを取得
<source lang="javascript" style="word-wrap:break-word;">
function getDocument($d)
</source>
*return:<Document>
;getSelection
:既定のSelectionを取得
<source lang="javascript" style="word-wrap:break-word;">
function getSelection()
</source>
*return:<Selection>
;setDefault
:既定のDocument/Selectionを指定
<source lang="javascript" style="word-wrap:break-word;">
function setDefault($d)
</source>
 
==KILIオブジェクトに含まれないもの==
==KILIオブジェクトに含まれないもの==
あまりにもよく使ってるので特別にグローバルに用意。よほどの事がない限りこれ以上増やさない。
あまりにもよく使ってるので特別にグローバルに用意。よほどの事がない限りこれ以上増やさない。
;GEO
;GEO
:Editorを取得
Editorを取得。
<source lang="javascript" style="word-wrap:break-word;">
function GEO(eIndex)
</source>
*eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
*eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
*return:<Document>
*return:<Document>
;GDO
;GDO
:Documentを取得
Documentを取得。
<source lang="javascript" style="word-wrap:break-word;">
function GDO(dIndex,eIndex)
</source>
*dIndex:<number> 文書のインデックス。不正な値の場合はアクティブ。
*dIndex:<number> 文書のインデックス。不正な値の場合はアクティブ。
*eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
*eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
*return:<Document>
*return:<Document>
;GSO
;GSO
:Selectionを取得
Selectionを取得。
<source lang="javascript" style="word-wrap:break-word;">
function GSO($d,eIndex)
</source>
*$d:<Document|number>
*$d:<Document|number>
**Document 対象のDocument。
**Document 対象のDocument。
106行目: 77行目:
*return:<Selection>
*return:<Selection>
;O
;O
:OutputBar.Writeln()へのショートカット<br />
OutputBar.Writeln()へのショートカット。<br />
null、undefinedは念のため文字列として出力。
null、undefinedは念のため文字列として出力。
<source lang="javascript" style="word-wrap:break-word;">
function O(data,nobreak,clear,focus)
</source>
*data:<Object> 出力データ。
*data:<Object> 出力データ。
*nobreak:<boolean> 改行しない。
*nobreak:<boolean> 改行しない。
116行目: 84行目:
*focus:<boolean> 出力ウィンドウにフォーカスを移す。
*focus:<boolean> 出力ウィンドウにフォーカスを移す。
;Seiko.run
;Seiko.run
:関数を指定回数実行して時間計測
関数を指定回数実行して時間計測。
<source lang="javascript" style="word-wrap:break-word;">
function Seiko.run(func,count)
</source>
*func:<Function> 計測する関数。
*func:<Function> 計測する関数。
*count:<number> 実行回数。
*count:<number> 実行回数。
127行目: 92行目:
Selection拡張。KILI.editと違い、文書は編集されない。
Selection拡張。KILI.editと違い、文書は編集されない。
;getBottomPos
;getBottomPos
:選択範囲の文末側の位置を取得
選択範囲の文末側の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getBottomPos($d)
</source>
;getDirection
;getDirection
:テキスト選択方向を取得
テキスト選択方向を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getDirection($d)
</source>
*return:<number> 0:無選択、1:順方向、-1:逆方向。
*return:<number> 0:無選択、1:順方向、-1:逆方向。
;getLineEndPos
;getLineEndPos
:全ての論理行末の位置を取得
全ての論理行末の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getLineEndPos($d)
</source>
*return:<Array>
*return:<Array>
;getLineHeadPos
;getLineHeadPos
:全ての論理行頭の位置を取得
全ての論理行頭の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getLineHeadPos($d)
</source>
*return:<Array>
*return:<Array>
;getRange
;getRange
:選択範囲を取得する
選択範囲を取得する。
<source lang="javascript" style="word-wrap:break-word;">
function getRange(posType,topToBottom,$d)
</source>
*posType:<number> 形式。*0:文頭からの位置、1:論理行、2:物理行。
*posType:<number> 形式。*0:文頭からの位置、1:論理行、2:物理行。
*topToBottom:<number> true:常に文頭側を開始位置とする、*false:選択方向に従う。
*topToBottom:<number> true:常に文頭側を開始位置とする、*false:選択方向に従う。
*return:<Object{start,end}>
*return:<Object{start,end}>
**start,end:<number|Object{x,y}> 開始位置、終了位置。
**start,end:<number|KILI.Point> 開始位置、終了位置。
;getTopPos
;getTopPos
:選択範囲の文頭側の位置を取得
選択範囲の文頭側の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getTolPos($d)
</source>
;getViewEndPos
;getViewEndPos
:全ての表示行末の位置を取得
全ての表示行末の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getViewEndPos($d)
</source>
;getViewHeadPos
;getViewHeadPos
:全ての表示行頭の位置を取得
全ての表示行頭の位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getViewHeadPos($d)
</source>
;getWrapPos
;getWrapPos
:全ての折り返し位置を取得
全ての折り返し位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function getWrapPos(asLogical,$d)
</source>
*asLogical:<boolean> 論理行・桁で返す。
*asLogical:<boolean> 論理行・桁で返す。
*return:<Array> @asLogicalがtrueならば各要素は{x,y}。
*return:<Array> @asLogicalがtrueならば各要素は{x,y}。
;isLogicalEnd
;aatLogicalEnd
:論理行末かどうか
論理行末かどうか。
<source lang="javascript" style="word-wrap:break-word;">
function isLogicalEnd(x,y,$d)
</source>
*x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
*x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
*y:<number> 表示行。*:@xを文頭からの位置とみなす。
*y:<number> 表示行。*:@xを文頭からの位置とみなす。
*return:<boolean>
*return:<boolean>
;isLogicalHead
;atLogicalHead
:論理行頭かどうか
論理行頭かどうか。
<source lang="javascript" style="word-wrap:break-word;">
function isLogicalHead(x,y,$d)
</source>
*x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
*x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
*y:<number> 表示行。*:@xを文頭からの位置とみなす。
*y:<number> 表示行。*:@xを文頭からの位置とみなす。
*return:<boolean>
*return:<boolean>
;logicalToPos
;logicalToPos
:論理行・桁を文頭からの位置に変換
論理行・桁を文頭からの位置に変換。
<source lang="javascript" style="word-wrap:break-word;">
*x:<KILI.Point||number>
function logicalToPos(x,y,$d)
**KILI.Point 論理行。
</source>
**number 論理行桁。
*x:<number> 論理行桁。
*y:<number> @xがnumberのとき、論理行。
*y:<number> 論理行。
*return:<number>
;logicalToView
;logicalToView
:論理行・桁を表示行・桁に変換
論理行・桁を表示行・桁に変換。
<source lang="javascript" style="word-wrap:break-word;">
*x:<KILI.Point||number>
function logicalToView(x,y,$d)
**KILI.Point 論理行。
</source>
**number 論理行桁。
*x:<number> 論理行桁。
*y:<number> @xがnumberのとき、論理行。
*y:<number> 論理行。
*return:<Object{x,y}>
;posToLogical
;posToLogical
:文頭からの位置を論理行・桁に変換
文頭からの位置を論理行・桁に変換。
<source lang="javascript" style="word-wrap:break-word;">
function posToLogical(pos,$d)
</source>
*pos:<number> 文頭からの位置。
*pos:<number> 文頭からの位置。
*return:<Object{x,y}>
*return:<KILI.Point>
;posToView
;posToView
:文頭からの位置を表示行・桁に変換
文頭からの位置を表示行・桁に変換。
<source lang="javascript" style="word-wrap:break-word;">
function posToView(pos,$d)
</source>
*pos:<number> 文頭からの位置。
*pos:<number> 文頭からの位置。
*return:<Object{x,y}>
*return:<KILI.Point>
;reverse
;reverse
:選択範囲を反転する
選択範囲を反転する。
<source lang="javascript" style="word-wrap:break-word;">
function reverse($d)
</source>
;searchTextLines
;searchTextLines
:文字列を含む論理行を取得
文字列を含む論理行を取得。
<source lang="javascript" style="word-wrap:break-word;">
function searchTextLines(seg,noText,$d)
</source>
*seg:<String||RegExp> 指定しない場合は選択部分。
*seg:<String||RegExp> 指定しない場合は選択部分。
*noText:<boolean> 文字列を含まない行を取得。
*noText:<boolean> 文字列を含まない行を取得。
*return:<Array>
*return:<Array>
;searchTextPos
;searchTextPos
:文字列を文書全体から探して位置を取得
文字列を文書全体から探して位置を取得。
<source lang="javascript" style="word-wrap:break-word;">
function searchTextPos(seg,$d)
</source>
*seg:<String||RegExp> 指定しない場合は選択部分。
*seg:<String||RegExp> 指定しない場合は選択部分。
*return:<Array>
*return:<Array>
;selectIfEmpty
;selectIfEmpty
:選択されていなければ選択する
選択されていなければ選択する。
<source lang="javascript" style="word-wrap:break-word;">
function selectIfEmpty(range,$d)
</source>
*range:<number> 選択範囲。*0:全体、1:論理行、2:表示行。
*range:<number> 選択範囲。*0:全体、1:論理行、2:表示行。
;selectLines
;selectLines
:複数の行を選択。
複数の行を選択。。
<source lang="javascript" style="word-wrap:break-word;">
function selectLines(from,count,selectBreak,asView,$d)
</source>
*from:<number> 開始行。
*from:<number> 開始行。
*num:<number> 選択行数。0:選択しない、負:文頭方向へ選択。
*num:<number> 選択行数。0:選択しない、負:文頭方向へ選択。
262行目: 169行目:
*asView:<boolean> 物理行で処理する。
*asView:<boolean> 物理行で処理する。
;setRange
;setRange
:範囲選択する
範囲選択する。
<source lang="javascript" style="word-wrap:break-word;">
*start,end:<number|KILI.Point> 開始位置、終了位置。
function setRange(start,end,asView,$d)
</source>
*start,end:<number|Object{x,y}> 開始位置、終了位置。
**number 文頭からの位置
**number 文頭からの位置
**Object *論理行での位置。@asViewがtrueなら表示行。
**Object *論理行での位置。@asViewがtrueなら表示行。
*asView:<boolean> @start,@endを表示行で指定する。
*asView:<boolean> @start,@endを表示行で指定する。
;viewToLogical
;viewToLogical
:表示行・桁を論理行・桁に変換
表示行・桁を論理行・桁に変換。
<source lang="javascript" style="word-wrap:break-word;">
*x:<KILI.Point||number>
function viewToLogical(x,y,$d)
**KILI.Point 表示行。
</source>
**number 表示行桁。
*x:<number> 表示行桁。
*y:<number> @xがnumberのとき、表示行。
*y:<number> 表示行。
*return:<KILI.Point>
*return:<Object{x,y}>
;viewToPos
;viewToPos
:表示行・桁を文書先頭からの位置に変換
表示行・桁を文書先頭からの位置に変換。
<source lang="javascript" style="word-wrap:break-word;">
*x:<KILI.Point||number>
function viewToPos(x,y,$d)
**KILI.Point 表示行。
</source>
**number 表示行桁。
*x:<number> 表示行桁。
*y:<number> @xがnumberのとき、表示行。
*y:<number> 表示行。
*return:<number>
*return:<number>


290行目: 192行目:
Selection拡張。KILI.selexと違い、文書は編集される。
Selection拡張。KILI.selexと違い、文書は編集される。
;breakAll
;breakAll
:文字列を全て改行にする
文字列を全て改行にする。
<source lang="javascript" style="word-wrap:break-word;">
function breakAll(seg,$d)
</source>
*seg:<String> 指定しない場合は選択部分。
*seg:<String> 指定しない場合は選択部分。
*return:<boolean> 置換したかどうか。
*return:<boolean> 置換したかどうか。
;deleteAll
;deleteAll
:文字列を全て削除
文字列を全て削除。
<source lang="javascript" style="word-wrap:break-word;">
function deleteAll(seg,$d)
</source>
*seg:<String> 指定しない場合は選択部分。
*seg:<String> 指定しない場合は選択部分。
*return:<boolean> 削除したかどうか。
*return:<boolean> 削除したかどうか。
;deleteAllNoTextLines
;deleteAllNoTextLines
:文字列を含まない行を全て削除
文字列を含まない行を全て削除。
<source lang="javascript" style="word-wrap:break-word;">
function deleteAllNoTextLines(seg,$d)
</source>
*seg:<String> 指定しない場合は選択部分。
*seg:<String> 指定しない場合は選択部分。
*return:<boolean> 削除したかどうか。
*return:<boolean> 削除したかどうか。
;deleteAllTextLines
;deleteAllTextLines
:文字列を含む行を全て削除
文字列を含む行を全て削除。
<source lang="javascript" style="word-wrap:break-word;">
function deleteAllTextLines(seg,$d)
</source>
*seg:<String> 指定しない場合は選択部分。
*seg:<String> 指定しない場合は選択部分。
*return:<boolean> 削除したかどうか。
*return:<boolean> 削除したかどうか。
;deleteLine
;deleteLine
:行削除
行削除。
<source lang="javascript" style="word-wrap:break-word;">
function deleteLine(line,asView,$d)
</source>
*line:<number> 削除行。
*line:<number> 削除行。
*asView:<boolean> true:表示行、*false:論理行。
*asView:<boolean> true:表示行、*false:論理行。
*return:<boolean> 削除したかどうか。
*return:<boolean> 削除したかどうか。
;deleteLines
;deleteLines
:行を全て削除
行を全て削除。
<source lang="javascript" style="word-wrap:break-word;">
function deleteLines(lines,asView,$d)
</source>
*lines:<Array> 行番号。
*lines:<Array> 行番号。
*asView:<boolean> true:表示行、*false:論理行。
*asView:<boolean> true:表示行、*false:論理行。
*return:<boolean> 削除したかどうか。
*return:<boolean> 削除したかどうか。
;duplicate
;duplicate
:論理行二重化
論理行二重化。
無選択時は現在の論理行、複数行選択時は範囲内の論理行、行内選択時は選択部分を二重化。
無選択時は現在の論理行、複数行選択時は範囲内の論理行、行内選択時は選択部分を二重化。
<source lang="javascript" style="word-wrap:break-word;">
function duplicate($d)
</source>
;sort
;sort
:テキストソート
テキストソート。
選択範囲の論理行が対象。無選択の場合は全体。行内選択の場合長さ順は無効。
選択範囲の論理行が対象。無選択の場合は全体。行内選択の場合長さ順は無効。
<source lang="javascript" style="word-wrap:break-word;">
function sort(sortType,$d)
</source>
*sortType:<number> ソートの種類。*0:逆順、1:昇順、2:降順、3:長さ昇順、4:長さ降順。
*sortType:<number> ソートの種類。*0:逆順、1:昇順、2:降順、3:長さ昇順、4:長さ降順。


351行目: 229行目:
あまり仕様が固まってないので激変の可能性あり。
あまり仕様が固まってないので激変の可能性あり。
;clone
;clone
:文書のクローンを作成
文書のクローンを作成。
<source lang="javascript" style="word-wrap:break-word;">
function clone(destination,$d)
</source>
*destination:<Editor> 文書作成先のEditor。*:アクティブ。
*destination:<Editor> 文書作成先のEditor。*:アクティブ。
*return:<Document> 作成した文書。
*return:<Document> 作成した文書。
;listupAll
;listupAll
:全てのDocumentを取得
全てのDocumentを取得。
<source lang="javascript" style="word-wrap:break-word;">
function listupAll(asObject)
</source>
*asObject:<boolean> 結果を{editorIndex:{documentIndex:Document}}の形式で返す。
*asObject:<boolean> 結果を{editorIndex:{documentIndex:Document}}の形式で返す。
*return:<Array||Object>
*return:<Array||Object>
;newFile
;newFile
:テキストとスタイルを指定して新規作成
テキストとスタイルを指定して新規作成。
<source lang="javascript" style="word-wrap:break-word;">
function newFile(text,encoding,mode,readOnly,overwrite,destination)
</source>
*text:<String>
*text:<String>
*encoding:<Document.Encoding> *:自動選択。
*encoding:<Document.Encoding> *:自動選択。
380行目: 249行目:
文字・コードポイントの相互変換とその表現を扱う。Unicodeのみが対象。
文字・コードポイントの相互変換とその表現を扱う。Unicodeのみが対象。
;decode
;decode
:コードポイントの配列を文字列に変換
コードポイントの配列を文字列に変換。
<source lang="javascript" style="word-wrap:break-word;">
function decode(code)
</source>
*code:<Array> 文字コードの配列。
*code:<Array> 文字コードの配列。
*return:<String>
*return:<String>
;decodeAll
;decodeAll
:文字列中のコード表現を文字列にする<br />
文字列中のコード表現を文字列にする。<br />
対応する形式
対応する形式
*U+hhhh
{|class="wikitable"
*\uhhhh
|U+hhhh||Unicode形式
*\x{hhhh}
|-
*&#dddd
|\uhhhh||正規表現
*&#xhhhh
|-
<source lang="javascript" style="word-wrap:break-word;">
|\x{hhhh}||鬼車などの正規表現
function decodeAll(seg)
|-
</source>
|&#dddd||実体参照(十進法)
|-
|&#xhhhh||実体参照(十六進法)
|}
*seg:<String>
*seg:<String>
*return:<String>
*return:<String>
;decodeSurrogate
;decodeSurrogate
:サロゲートペアをコードポイントに変換
サロゲートペアをコードポイントに変換。
<source lang="javascript" style="word-wrap:break-word;">
function decodeSurrogate(higher,lower)
</source>
*higher,lower:<number> 上位・下位サロゲート。
*higher,lower:<number> 上位・下位サロゲート。
*return:<number>
*return:<number>
;encode
;encode
:文字列をコードポイントの配列に変換
文字列をコードポイントの配列に変換。
<source lang="javascript" style="word-wrap:break-word;">
function encode(seg,surrogate,alignmentString)
</source>
*seg:<String>
*seg:<String>
*surrogate:<boolean> サロゲートペアで出力する。
*surrogate:<boolean> サロゲートペアで出力する。
416行目: 279行目:
*return:<Array>
*return:<Array>
;encodeSurrogate
;encodeSurrogate
:コードポイントをサロゲートペアで表現<br />
コードポイントをサロゲートペアで表現。<br />
コードポイントが0x10000未満の場合そのまま返す。
コードポイントが0x10000未満の場合そのまま返す。
<source lang="javascript" style="word-wrap:break-word;">
function encodeSurrogate(code)
</source>
*code:<number>
*code:<number>
*return:<Array[high,low]|number>
*return:<Array[high,low]|number>
;fromCharCode
;fromCharCode
:0x10000以上にも対応したfromCharCode<br />
0x10000以上にも対応したfromCharCode。<br />
引数・戻り値はfromCharCodeと同じ。
引数・戻り値はfromCharCodeと同じ。
<source lang="javascript" style="word-wrap:break-word;">
function fromCharCode(arg,...)
</source>
*args:<number>
*args:<number>
*return:<string>
*return:<string>
;fromEntity
;fromEntity
:文字列中の数値実体参照(&#dddd,&#xhhhh)を文字に変換
文字列中の数値実体参照(&#dddd,&#xhhhh)を文字に変換。
<source lang="javascript" style="word-wrap:break-word;">
function fromEntity(seg,radix)
</source>
*seg:<String>
*seg:<String>
*radix:<boolean> true:十進数のみ、false:十六進数のみ、*:両方。
*radix:<boolean> true:十進数のみ、false:十六進数のみ、*:両方。
*return:<String>
*return:<String>
;fromOnig
;fromOnig
:文字列中の鬼車のコード表現(\x{hhhh})を文字に変換
文字列中の鬼車のコード表現(\x{hhhh})を文字に変換。
<source lang="javascript" style="word-wrap:break-word;">
function fromOnig(seg)
</source>
*seg:<String>
*seg:<String>
*return:<String>
*return:<String>
;fromRegex
;fromRegex
:文字列中の正規表現のコード表現(\uhhhh)を文字に変換
文字列中の正規表現のコード表現(\uhhhh)を文字に変換。
<source lang="javascript" style="word-wrap:break-word;">
function fromRegex(seg)
</source>
*seg:<String>
*seg:<String>
*return:<String>
*return:<String>
;fromUnicode
;fromUnicode
:文字列中のUnicodeのコード表現(U+hhhh)を文字に変換
文字列中のUnicodeのコード表現(U+hhhh)を文字に変換。
<source lang="javascript" style="word-wrap:break-word;">
function fromUnicode(seg)
</source>
*seg:<String>
*seg:<String>
*return:<String>
*return:<String>
;toEntity
;toEntity
:文字列を数値実体参照(&#dddd,&#xhhhh)に変換
文字列を数値実体参照(&#dddd,&#xhhhh)に変換。
<source lang="javascript" style="word-wrap:break-word;">
function toEntity(seg,surrogate,alignmentString,radix)
</source>
*seg:<String>
*seg:<String>
*surrogate:<boolean> サロゲートペアで出力する。
*surrogate:<boolean> サロゲートペアで出力する。
471行目: 313行目:
*return:<String>
*return:<String>
;toOnig
;toOnig
:文字列を鬼車のコード表現(\x{hhhh})に変換
文字列を鬼車のコード表現(\x{hhhh})に変換。
<source lang="javascript" style="word-wrap:break-word;">
function toOnig(seg,surrogate,alignmentString)
</source>
*seg:<String>
*seg:<String>
*surrogate:<boolean> サロゲートペアで出力する。
*surrogate:<boolean> サロゲートペアで出力する。
480行目: 319行目:
*return:<String>
*return:<String>
;toRegex
;toRegex
:文字列を正規表現のコード表現(\uhhhh)に変換
文字列を正規表現のコード表現(\uhhhh)に変換。
<source lang="javascript" style="word-wrap:break-word;">
function toRegex(seg,surrogate,alignmentString)
</source>
*seg:<String>
*seg:<String>
*surrogate:<boolean> サロゲートペアで出力する。
*surrogate:<boolean> サロゲートペアで出力する。
489行目: 325行目:
*return:<String>
*return:<String>
;toUnicode
;toUnicode
:文字列をUnicodeのコード表現(U+hhhh)に変換
文字列をUnicodeのコード表現(U+hhhh)に変換。
<source lang="javascript" style="word-wrap:break-word;">
function toUnicode(seg,surrogate,alignmentString)
</source>
*seg:<String>
*seg:<String>
*surrogate:<boolelan> サロゲートペアで出力する。
*surrogate:<boolelan> サロゲートペアで出力する。
503行目: 336行目:
組み込みArray拡張。
組み込みArray拡張。
;clone
;clone
:配列を値渡し
配列を値渡し。
<source lang="javascript" style="word-wrap:break-word;">
function clone()
</source>
*return:<Array>
*return:<Array>
;compact
;compact
:空文字列、null、undefinedを削除する
空文字列、null、undefinedを削除する。
<source lang="javascript" style="word-wrap:break-word;">
function compact()
</source>
*return:<Array>
*return:<Array>
;del
;del
:一致した要素を削除
一致した要素を削除。
<source lang="javascript" style="word-wrap:break-word;">
function del(arg,...)
</source>
*args:<*> 削除する要素。
*args:<*> 削除する要素。
*return:<Array>
*return:<Array>
;indexOf
;indexOf
:配列から文字列を検索
配列から文字列を検索。
<source lang="javascript" style="word-wrap:break-word;">
function indexOf(str,from)
</source>
*str:<string> 検索文字列。
*str:<string> 検索文字列。
*from:<number> 検索開始インデックス。
*from:<number> 検索開始インデックス。
*return:<number> 配列インデックス。見つからなければ-1。
*return:<number> 配列インデックス。見つからなければ-1。
;insert
;insert
:要素を挿入する
要素を挿入する。
<source lang="javascript" style="word-wrap:break-word;">
function insert(pos,itte)
</source>
*pos:<number> 挿入位置。
*pos:<number> 挿入位置。
*item:<Object> 挿入要素。
*item:<Object> 挿入要素。
*return:<Array>
*return:<Array>
;last
;last
:配列の最後の要素を返す
配列の最後の要素を返す。
<source lang="javascript" style="word-wrap:break-word;">
function last()
</source>
*return:<*>
*return:<*>
;mine
;mine
:指定条件にマッチする要素を集める
指定条件にマッチする要素を集める。
<source lang="javascript" style="word-wrap:break-word;">
function mine(func,returnElement)
</source>
*func:<Function(element)> 条件を判定する関数。
*func:<Function(element)> 条件を判定する関数。
**element:<*> 配列の各要素。
**element:<*> 配列の各要素。
553行目: 365行目:
*returnElement:<boolean> true:要素自体を返す。false:インデックスを返す。
*returnElement:<boolean> true:要素自体を返す。false:インデックスを返す。
*return:<Array>
*return:<Array>
;e.g.
e.g.
:<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
[1,2,3,4,5].mine(function(e){return e%2;}); //[0,2,4]
[1,2,3,4,5].mine(function(e){return e%2;}); //[0,2,4]
[1,2,3,4,5].mine(function(e){return e%2;},true); //[1,3,5]
[1,2,3,4,5].mine(function(e){return e%2;},true); //[1,3,5]
</source>
</source>
;pickup
 
:指定したインデックスの要素を取り出した配列を返す
;pickup。
<source lang="javascript" style="word-wrap:break-word;">
指定したインデックスの要素を取り出した配列を返す。
function pickup(arg,...)
</source>
*args:<number> 取り出す要素のインデックス。
*args:<number> 取り出す要素のインデックス。
*return:<Array>
*return:<Array>
;e.g.
e.g.
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
[1,2,3,4,5,6].pickup(2,5,1); //[3,6,2]
[{a:1,b:2},{a:3,c:4},{a:5,d:6}].siblings("a"); //[1,3,5];
</source>
</source>
;siblings
;siblings
:オブジェクトの配列の各要素から同名のプロパティを取得
オブジェクトの配列の各要素から同名のプロパティを取得。
<source lang="javascript" style="word-wrap:break-word;">
function siblings(name)
</source>
*name:<string> プロパティ名。
*name:<string> プロパティ名。
*return:<Array>
*return:<Array>
;e.g.
e.g.
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
[{a:1,b:2},{a:3,c:4},{a:5,d:6}].siblings("a"); //[1,3,5];
[{a:1,b:2},{a:3,c:4},{a:5,d:6}].siblings("a"); //[1,3,5];
</source>
</source>
;undup
;undup
:配列から重複を削除
配列から重複を削除。
<source lang="javascript" style="word-wrap:break-word;">
function undup()
</source>
*return:<Array>
*return:<Array>


590行目: 394行目:
Numberオブジェクト拡張
Numberオブジェクト拡張
;constrain
;constrain
:数値を範囲内に収める
数値を範囲内に収める。
<source lang="javascript" style="word-wrap:break-word;">
function constrain(min,max)
</source>
*min,max:<number> 最小値、最大値。
*min,max:<number> 最小値、最大値。
*return:<number>
*return:<number>
;inRange
;inRange
:n以上m以下
n以上m以下。
<source lang="javascript" style="word-wrap:break-word;">
function inRange(r1,r2)
</source>
*r1,r2:<number> 範囲。大小の順は不問。
*r1,r2:<number> 範囲。大小の順は不問。
*return:<boolean>
*return:<boolean>
;padding
;padding
:桁揃え<br />
桁揃え。<br />
文字列としての長さが@digitより長い場合、切り捨ては行わない。
文字列としての長さが@digitより長い場合、切り捨ては行わない。
<source lang="javascript" style="word-wrap:break-word;">
function padding(digit,pad)
</source>
*digit:<number> 全体の桁数。*4。
*digit:<number> 全体の桁数。*4。
*pad:<string> 埋め文字。*0。
*pad:<string> 埋め文字。*0。
*return:<string>
*return:<string>
;toHexString
;toHexString
:十六進数表記で返す
十六進数表記で返す。
<source lang="javascript" style="word-wrap:break-word;">
function toHexString()
</source>
*return:<string>
*return:<string>


622行目: 414行目:
Stringオブジェクト拡張
Stringオブジェクト拡張
;crlf
;crlf
:改行をCRLFにする
改行をCRLFにする。
<source lang="javascript" style="word-wrap:break-word;">
function crlf()
</source>
*return:<string>
*return:<string>
;cut
;cut
:指定の長さで分割
指定の長さで分割。
<source lang="javascript" style="word-wrap:break-word;">
function cut(arg,...)
</source>
*args[0]:<number> 最初の分割長。argsが1つだけの場合、負:分割しない、0:(0,false)と同じ、正:その長さで全体を分割する。
*args[0]:<number> 最初の分割長。argsが1つだけの場合、負:分割しない、0:(0,false)と同じ、正:その長さで全体を分割する。
*args[1-]:<number|boolean>
*args[1-]:<number|boolean>
637行目: 423行目:
**boolean ここで処理を中断する。true:残りを出力しない、*false:残りを1つの要素として出力する。
**boolean ここで処理を中断する。true:残りを出力しない、*false:残りを1つの要素として出力する。
*return:<Array>
*return:<Array>
;e.g.
e.g.
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
"abcdefgh".cut(2); //[ab,cd,ef,gh]
"abcdefgh".cut(2); //[ab,cd,ef,gh]
645行目: 431行目:
;dQuot
;dQuot
「"」で囲む
「"」で囲む
<source lang="javascript" style="word-wrap:break-word;">
function dQuot()
</source>
*return:<string>
*return:<string>
;enclose
;enclose
:指定の文字列で囲む
指定の文字列で囲む。
<source lang="javascript" style="word-wrap:break-word;">
function enclose(pre,post)
</source>
*pre:<string> 囲み開き文字。
*pre:<string> 囲み開き文字。
*post:<string> 囲み閉じ文字。*:@preと同じ。
*post:<string> 囲み閉じ文字。*:@preと同じ。
*return:<string>
*return:<string>
;enclosed
;enclosed
:文字列で囲まれている
文字列で囲まれている。
<source lang="javascript" style="word-wrap:break-word;">
function enclosed(pre,post,ignoreCase)
</source>
*pre:<string> 囲み開き文字。
*pre:<string> 囲み開き文字。
*post:<string> 囲み閉じ文字。*:@preと同じ。
*post:<string> 囲み閉じ文字。*:@preと同じ。
667行目: 444行目:
*return:<boolean>
*return:<boolean>
;endsWith
;endsWith
:末尾にマッチする
末尾にマッチする。
<source lang="javascript" style="word-wrap:break-word;">
function endsWith(seg,ignoreCase)
</source>
*seg:<string> マッチ文字列。
*seg:<string> マッチ文字列。
*ignoreCase:<boolean> 大文字小文字を無視する。
*ignoreCase:<boolean> 大文字小文字を無視する。
*return:<boolean>
*return:<boolean>
;insert
;insert
:文字列を挿入する
文字列を挿入する。
<source lang="javascript" style="word-wrap:break-word;">
function insert(seg,pos)
</source>
*seg:<string> 挿入する文字列。
*seg:<string> 挿入する文字列。
*pos:<number> 挿入位置。
*pos:<number> 挿入位置。
*return:<string>
*return:<string>
;repeat
;repeat
:文字列を繰り返す
文字列を繰り返す。
<source lang="javascript" style="word-wrap:break-word;">
function repeat(count)
</source>
*count:<number> 繰り返し回数。
*count:<number> 繰り返し回数。
*return:<string>
*return:<string>
;sQuot
;sQuot
:「'」で囲む
「'」で囲む。
<source lang="javascript" style="word-wrap:break-word;">
function sQuot()
</source>
*return:<string>
*return:<string>
;startsWith
;startsWith
:先頭にマッチする
先頭にマッチする。
<source lang="javascript" style="word-wrap:break-word;">
function startsWith(seg,ignoreCase)
</source>
*seg:<string> マッチ文字列。
*seg:<string> マッチ文字列。
*ignoreCase:<boolean> 大文字小文字を無視する。
*ignoreCase:<boolean> 大文字小文字を無視する。
707行目: 469行目:
テキストと実行コマンドのみからなる単純なPopupMenu。
テキストと実行コマンドのみからなる単純なPopupMenu。
;メニューの定義
;メニューの定義
<source lang="javascript" style="word-wrap:break-word;">
var menu=[[text,command],...];
</source>
*text:<string> メニューのテキスト。
*text:<string> メニューのテキスト。
*command:<Function||Array>  
*command:<Function||Array>  
**Function:メニュー選択時に実行する関数。
**Function:メニュー選択時に実行する関数。
**Array:サブメニュー。
**Array:サブメニュー。空の配列の場合、区切りとなる。
空の配列の場合、区切りとなる。
e.g.
;e.g.
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
var menu=[
var menu=[
  ["a",function(){Alert("a");}], //関数を実行する
["a",function(){Alert("a");}], //関数を実行する
  [],
[], //区切り
  ["b",[
["b",[
    ["b-a",function(){return ["b","a"];}], //配列を返す
["b-a",function(){return ["b","a"];}], //配列を返す
    ["b-c","b-c"] //文字列を返す
["b-c","b-c"] //文字列を返す
  ]]
]]
]
]
var p=new SimplePM();
var p=new SimplePM();
729行目: 487行目:
p.track();
p.track();
</source>
</source>
==メソッド==
;create
;create
:メニューを作成
メニューを作成。
<source lang="javascript" style="word-wrap:break-word;">
function create(menu,returnPopupMenu)
</source>
*menu:<Array> メニュー定義の配列。
*menu:<Array> メニュー定義の配列。
*returnPopupMenu:<boolean> true:PopupMenuを返す、*false:自身を返す。
*returnPopupMenu:<boolean> true:PopupMenuを返す、*false:自身を返す。
*return:<PopupMenu||PPM>
*return:<PopupMenu||PPM>
;getCommand
;getCommand
:IDの項目のコマンドを返す
IDの項目のコマンドを返す。
<source lang="javascript" style="word-wrap:break-word;">
function getCommand(id)
</source>
*id:<number> ID。
*id:<number> ID。
*return:<*> 未定義の場合はテキストを返す。
*return:<*> 未定義の場合はテキストを返す。
;getIdFromPosition
;getIdFromPosition
:メニューの位置からIDを取得
メニューの位置からIDを取得。
<source lang="javascript" style="word-wrap:break-word;">
function getIdFromPosition(pos)
</source>
*pos:<string> 位置。0起点で、上位の階層とは「-」で繋ぐ。
*pos:<string> 位置。0起点で、上位の階層とは「-」で繋ぐ。
*return:<number||undefined>
*return:<number||undefined>
;e.g.(冒頭の続き)
e.g.(冒頭の続き)
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
p.getText(p.getIdFromPosition("2-1")); //"b-c"
p.getText(p.getIdFromPosition("2-1")); //"b-c"
</source>
</source>
;getResult
;getResult
:前回の実行結果を返す
前回の実行結果を返す。
<source lang="javascript" style="word-wrap:break-word;">
function getResult()
</source>
*return:<Object{id,result}> trackを参照。
*return:<Object{id,result}> trackを参照。
;getText
;getText
:IDの項目のテキストを返す
IDの項目のテキストを返す。
<source lang="javascript" style="word-wrap:break-word;">
function getText(menu,returnPopupMenu)
</source>
*id:<number> ID。
*id:<number> ID。
;modify
;modify
:メニューの一部を変更する
メニューの一部を変更する。
<source lang="javascript" style="word-wrap:break-word;">
function modify(id,item)
</source>
*id:<number> アイテムのID。
*id:<number> アイテムのID。
*@item:<command> 置き換えるメニューの定義。
*@item:<command> 置き換えるメニューの定義。
;e.g.(冒頭の続き)
e.g.(冒頭の続き)
<source lang="javascript" style="word-wrap:break-word;">
<source lang="javascript" style="word-wrap:break-word;">
p.modify(p.getIdFromPosition("2-1"),menu[0]);
p.modify(p.getIdFromPosition("2-1"),menu[0]);
</source>
</source>
;track
;track
:メニューを表示、コマンドを実行
メニューを表示、コマンドを実行。<br />
コマンドが関数・配列でない場合はその値を返す。関数・配列を返したい場合は関数内でreturnする。
コマンドが関数・配列でない場合はその値を返す。関数・配列を返したい場合は関数内でreturnする。
<source lang="javascript" style="word-wrap:break-word;">
function track(pos,returnId)
</source>
*pos:<number> *0:カーソル位置に表示、1:キャレット位置に表示。
*pos:<number> *0:カーソル位置に表示、1:キャレット位置に表示。
*returnId:<boolean> コマンド未定義の場合の返り値。true:ID、*false:メニューのテキスト。
*returnId:<boolean> コマンド未定義の場合の返り値。true:ID、*false:メニューのテキスト。

2015年4月7日 (火) 17:07時点における版

Ginnieから移行中。何か変な所があったらその癖が抜けてないせいです……

覚え書き

Document.GetLine

デフォルトでは表示行を取得。meGetLineLogicalが未定義なので0を指定する。

最初の数
  • 行:1 (Document.GetLine)
  • 文頭からの位置:0 (Selection.GetActivePos)
  • 桁:1 (Selection.GetActivePointX)
  • Editor,Document:0 (Editors.Item.Documents.Item)
Window.Document

Document.NewFile後も更新されない。

Editor.ActiveDocument.NewFile();
Alert(Document.Text);
Editor.FindInFiles
  • ディレクトリ名は最後を"\\"か"\\*"にする。
  • アクティブな文書が結果表示で乗っ取られる。
PopupMenu.Track
  • 引数無しだとエラー。0でキャレット位置に表示。mePosMouseは1。
  • キャンセルした場合の返り値は0。
  • 返り値を変数に入れるなりOutputするなりしないとメニューは表示されない。
  • 領域外をクリックしてキャンセルした場合、続けてTrackしていても実行されない。Escでだとされる。
var p=CreatePopupMenu();
p.Add("1");
var x=p.Track(0);	//ここでキャンセル
if(x==0){
  x=p.Track(0);
}
Selection.Replace

検索文字列が0x000aから始まるとき、meFindReplaceRegExpを指定しないと、meReplaceAllがおかしい。

Selection.Replace("\n","",meReplaceAll);	//最初の1つだけ処理される
Selection.Replace(";\n","",meReplaceAll);	//全て処理される
Selection.Replace("\n;","",meReplaceAll);	//最初の1つだけ処理される
Document.Text

代入する場合、設定上の改行コードがCRLFでも、改行記号は文字列中の改行によって変わる。

$d.Text=$d.Text	//改行記号はLFになる
include/StateBackup.js

表示行頭がActive/Anchorになる様な範囲の場合、Restoreするとそれぞれ直前の表示行末に移動する。
mePosLogicalをmePosViewに変えるといい。

KILI.js

グローバルに用意しているのはこの「KILI」オブジェクトと次の項に挙げたいくつかのみ。
(これ以外のファイルでも)引数のコメントで「*」が付いてるものは既定値。

よく出てくる変数名
  • $d:対象となる文書のDocument。
  • $s:対象となる文書のSelection。
  • SB:StateBackup。

$d

ほぼ全てのメソッドは最後の引数に「$d」を取る。これが指定されていない場合はアクティブな文書を対象とする。

オブジェクト

Point

座標を表すオブジェクト。今のところx,yが含まれているだけ。

KILIオブジェクトに含まれないもの

あまりにもよく使ってるので特別にグローバルに用意。よほどの事がない限りこれ以上増やさない。

GEO

Editorを取得。

  • eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
  • return:<Document>
GDO

Documentを取得。

  • dIndex:<number> 文書のインデックス。不正な値の場合はアクティブ。
  • eIndex:<number> エディタのインデックス。不正な値の場合はアクティブ。
  • return:<Document>
GSO

Selectionを取得。

  • $d:<Document|number>
    • Document 対象のDocument。
    • number 文書のインデックス。*undefined:アクティブ。
  • eIndex:<number> @$dで#numberを指定した場合、エディタのインデックス。
  • return:<Selection>
O

OutputBar.Writeln()へのショートカット。
null、undefinedは念のため文字列として出力。

  • data:<Object> 出力データ。
  • nobreak:<boolean> 改行しない。
  • clear:<boolean> 出力前にウィンドウをクリアする。
  • focus:<boolean> 出力ウィンドウにフォーカスを移す。
Seiko.run

関数を指定回数実行して時間計測。

  • func:<Function> 計測する関数。
  • count:<number> 実行回数。
  • return:<number> 経過時間。

KILI.selex

Selection拡張。KILI.editと違い、文書は編集されない。

getBottomPos

選択範囲の文末側の位置を取得。

getDirection

テキスト選択方向を取得。

  • return:<number> 0:無選択、1:順方向、-1:逆方向。
getLineEndPos

全ての論理行末の位置を取得。

  • return:<Array>
getLineHeadPos

全ての論理行頭の位置を取得。

  • return:<Array>
getRange

選択範囲を取得する。

  • posType:<number> 形式。*0:文頭からの位置、1:論理行、2:物理行。
  • topToBottom:<number> true:常に文頭側を開始位置とする、*false:選択方向に従う。
  • return:<Object{start,end}>
    • start,end:<number|KILI.Point> 開始位置、終了位置。
getTopPos

選択範囲の文頭側の位置を取得。

getViewEndPos

全ての表示行末の位置を取得。

getViewHeadPos

全ての表示行頭の位置を取得。

getWrapPos

全ての折り返し位置を取得。

  • asLogical:<boolean> 論理行・桁で返す。
  • return:<Array> @asLogicalがtrueならば各要素は{x,y}。
aatLogicalEnd

論理行末かどうか。

  • x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
  • y:<number> 表示行。*:@xを文頭からの位置とみなす。
  • return:<boolean>
atLogicalHead

論理行頭かどうか。

  • x:<number> 表示行桁もしくは文頭からの位置。*:現在位置。
  • y:<number> 表示行。*:@xを文頭からの位置とみなす。
  • return:<boolean>
logicalToPos

論理行・桁を文頭からの位置に変換。

  • x:<KILI.Point||number>
    • KILI.Point 論理行。
    • number 論理行桁。
  • y:<number> @xがnumberのとき、論理行。
logicalToView

論理行・桁を表示行・桁に変換。

  • x:<KILI.Point||number>
    • KILI.Point 論理行。
    • number 論理行桁。
  • y:<number> @xがnumberのとき、論理行。
posToLogical

文頭からの位置を論理行・桁に変換。

  • pos:<number> 文頭からの位置。
  • return:<KILI.Point>
posToView

文頭からの位置を表示行・桁に変換。

  • pos:<number> 文頭からの位置。
  • return:<KILI.Point>
reverse

選択範囲を反転する。

searchTextLines

文字列を含む論理行を取得。

  • seg:<String||RegExp> 指定しない場合は選択部分。
  • noText:<boolean> 文字列を含まない行を取得。
  • return:<Array>
searchTextPos

文字列を文書全体から探して位置を取得。

  • seg:<String||RegExp> 指定しない場合は選択部分。
  • return:<Array>
selectIfEmpty

選択されていなければ選択する。

  • range:<number> 選択範囲。*0:全体、1:論理行、2:表示行。
selectLines

複数の行を選択。。

  • from:<number> 開始行。
  • num:<number> 選択行数。0:選択しない、負:文頭方向へ選択。
  • selectBreak:<boolean> true:選択終了位置の改行も選択する、*false:改行前まで。
  • asView:<boolean> 物理行で処理する。
setRange

範囲選択する。

  • start,end:<number|KILI.Point> 開始位置、終了位置。
    • number 文頭からの位置
    • Object *論理行での位置。@asViewがtrueなら表示行。
  • asView:<boolean> @start,@endを表示行で指定する。
viewToLogical

表示行・桁を論理行・桁に変換。

  • x:<KILI.Point||number>
    • KILI.Point 表示行。
    • number 表示行桁。
  • y:<number> @xがnumberのとき、表示行。
  • return:<KILI.Point>
viewToPos

表示行・桁を文書先頭からの位置に変換。

  • x:<KILI.Point||number>
    • KILI.Point 表示行。
    • number 表示行桁。
  • y:<number> @xがnumberのとき、表示行。
  • return:<number>

KILI.edit

Selection拡張。KILI.selexと違い、文書は編集される。

breakAll

文字列を全て改行にする。

  • seg:<String> 指定しない場合は選択部分。
  • return:<boolean> 置換したかどうか。
deleteAll

文字列を全て削除。

  • seg:<String> 指定しない場合は選択部分。
  • return:<boolean> 削除したかどうか。
deleteAllNoTextLines

文字列を含まない行を全て削除。

  • seg:<String> 指定しない場合は選択部分。
  • return:<boolean> 削除したかどうか。
deleteAllTextLines

文字列を含む行を全て削除。

  • seg:<String> 指定しない場合は選択部分。
  • return:<boolean> 削除したかどうか。
deleteLine

行削除。

  • line:<number> 削除行。
  • asView:<boolean> true:表示行、*false:論理行。
  • return:<boolean> 削除したかどうか。
deleteLines

行を全て削除。

  • lines:<Array> 行番号。
  • asView:<boolean> true:表示行、*false:論理行。
  • return:<boolean> 削除したかどうか。
duplicate

論理行二重化。 無選択時は現在の論理行、複数行選択時は範囲内の論理行、行内選択時は選択部分を二重化。

sort

テキストソート。 選択範囲の論理行が対象。無選択の場合は全体。行内選択の場合長さ順は無効。

  • sortType:<number> ソートの種類。*0:逆順、1:昇順、2:降順、3:長さ昇順、4:長さ降順。

KILI.docex

Document拡張。Editorの領分と思われるものも含む。
あまり仕様が固まってないので激変の可能性あり。

clone

文書のクローンを作成。

  • destination:<Editor> 文書作成先のEditor。*:アクティブ。
  • return:<Document> 作成した文書。
listupAll

全てのDocumentを取得。

  • asObject:<boolean> 結果を{editorIndex:{documentIndex:Document}}の形式で返す。
  • return:<Array||Object>
newFile

テキストとスタイルを指定して新規作成。

  • text:<String>
  • encoding:<Document.Encoding> *:自動選択。
  • mode:<Document.Mode> *:Text
  • readOnly:<Document.ReadOnly> *:false
  • overwrite:<Selection.OverwriteMode> *:false
  • destination:<Editor> 文書作成先のEditor。*:アクティブ。
  • return:<Document> 作成した文書。

KILI.code.js

文字・コードポイントの相互変換とその表現を扱う。Unicodeのみが対象。

decode

コードポイントの配列を文字列に変換。

  • code:<Array> 文字コードの配列。
  • return:<String>
decodeAll

文字列中のコード表現を文字列にする。
対応する形式

U+hhhh Unicode形式
\uhhhh 正規表現
\x{hhhh} 鬼車などの正規表現
&#dddd 実体参照(十進法)
&#xhhhh 実体参照(十六進法)
  • seg:<String>
  • return:<String>
decodeSurrogate

サロゲートペアをコードポイントに変換。

  • higher,lower:<number> 上位・下位サロゲート。
  • return:<number>
encode

文字列をコードポイントの配列に変換。

  • seg:<String>
  • surrogate:<boolean> サロゲートペアで出力する。
  • alignmentString:<number> 指定した桁数の文字列で出力する。
  • return:<Array>
encodeSurrogate

コードポイントをサロゲートペアで表現。
コードポイントが0x10000未満の場合そのまま返す。

  • code:<number>
  • return:<Array[high,low]|number>
fromCharCode

0x10000以上にも対応したfromCharCode。
引数・戻り値はfromCharCodeと同じ。

  • args:<number>
  • return:<string>
fromEntity

文字列中の数値実体参照(&#dddd,&#xhhhh)を文字に変換。

  • seg:<String>
  • radix:<boolean> true:十進数のみ、false:十六進数のみ、*:両方。
  • return:<String>
fromOnig

文字列中の鬼車のコード表現(\x{hhhh})を文字に変換。

  • seg:<String>
  • return:<String>
fromRegex

文字列中の正規表現のコード表現(\uhhhh)を文字に変換。

  • seg:<String>
  • return:<String>
fromUnicode

文字列中のUnicodeのコード表現(U+hhhh)を文字に変換。

  • seg:<String>
  • return:<String>
toEntity

文字列を数値実体参照(&#dddd,&#xhhhh)に変換。

  • seg:<String>
  • surrogate:<boolean> サロゲートペアで出力する。
  • alignmentString:<number> 指定した桁数の文字列で出力する。
  • radix:<boolean> true:十進数表記、*false:十六進数表記。
  • return:<String>
toOnig

文字列を鬼車のコード表現(\x{hhhh})に変換。

  • seg:<String>
  • surrogate:<boolean> サロゲートペアで出力する。
  • alignmentString:<number> 指定した桁数の文字列で出力する。
  • return:<String>
toRegex

文字列を正規表現のコード表現(\uhhhh)に変換。

  • seg:<String>
  • surrogate:<boolean> サロゲートペアで出力する。
  • alignmentString:<number> 指定した桁数の文字列で出力する。
  • return:<String>
toUnicode

文字列をUnicodeのコード表現(U+hhhh)に変換。

  • seg:<String>
  • surrogate:<boolelan> サロゲートペアで出力する。
  • alignmentString:<number> 指定した桁数の文字列で出力する。
  • return:<String>

組み込みオブジェクト拡張

名前の衝突に注意。特にStringExはincludeライブラリのStringExと衝突しています。

ArrayEx.js

組み込みArray拡張。

clone

配列を値渡し。

  • return:<Array>
compact

空文字列、null、undefinedを削除する。

  • return:<Array>
del

一致した要素を削除。

  • args:<*> 削除する要素。
  • return:<Array>
indexOf

配列から文字列を検索。

  • str:<string> 検索文字列。
  • from:<number> 検索開始インデックス。
  • return:<number> 配列インデックス。見つからなければ-1。
insert

要素を挿入する。

  • pos:<number> 挿入位置。
  • item:<Object> 挿入要素。
  • return:<Array>
last

配列の最後の要素を返す。

  • return:<*>
mine

指定条件にマッチする要素を集める。

  • func:<Function(element)> 条件を判定する関数。
    • element:<*> 配列の各要素。
    • return:<boolean>
  • returnElement:<boolean> true:要素自体を返す。false:インデックスを返す。
  • return:<Array>

e.g.

[1,2,3,4,5].mine(function(e){return e%2;});	//[0,2,4]
[1,2,3,4,5].mine(function(e){return e%2;},true);	//[1,3,5]
pickup。

指定したインデックスの要素を取り出した配列を返す。

  • args:<number> 取り出す要素のインデックス。
  • return:<Array>

e.g.

[{a:1,b:2},{a:3,c:4},{a:5,d:6}].siblings("a");	//[1,3,5];
siblings

オブジェクトの配列の各要素から同名のプロパティを取得。

  • name:<string> プロパティ名。
  • return:<Array>

e.g.

[{a:1,b:2},{a:3,c:4},{a:5,d:6}].siblings("a");	//[1,3,5];
undup

配列から重複を削除。

  • return:<Array>

NumberEx.js

Numberオブジェクト拡張

constrain

数値を範囲内に収める。

  • min,max:<number> 最小値、最大値。
  • return:<number>
inRange

n以上m以下。

  • r1,r2:<number> 範囲。大小の順は不問。
  • return:<boolean>
padding

桁揃え。
文字列としての長さが@digitより長い場合、切り捨ては行わない。

  • digit:<number> 全体の桁数。*4。
  • pad:<string> 埋め文字。*0。
  • return:<string>
toHexString

十六進数表記で返す。

  • return:<string>

StringEx.js

Stringオブジェクト拡張

crlf

改行をCRLFにする。

  • return:<string>
cut

指定の長さで分割。

  • args[0]:<number> 最初の分割長。argsが1つだけの場合、負:分割しない、0:(0,false)と同じ、正:その長さで全体を分割する。
  • args[1-]:<number|boolean>
    • number 2番目以降の分割長。0:空要素となる。負:その分遡る。
    • boolean ここで処理を中断する。true:残りを出力しない、*false:残りを1つの要素として出力する。
  • return:<Array>

e.g.

"abcdefgh".cut(2);	//[ab,cd,ef,gh]
"abcdefgh".cut(1,2,3,true);	//[a,bc,def]
"abcdefgh".cut(1,-2,3,-1);	//[a,abc,cdefgh]
dQuot

「"」で囲む

  • return:<string>
enclose

指定の文字列で囲む。

  • pre:<string> 囲み開き文字。
  • post:<string> 囲み閉じ文字。*:@preと同じ。
  • return:<string>
enclosed

文字列で囲まれている。

  • pre:<string> 囲み開き文字。
  • post:<string> 囲み閉じ文字。*:@preと同じ。
  • ignoreCase:<boolean> 大文字小文字を無視する。
  • return:<boolean>
endsWith

末尾にマッチする。

  • seg:<string> マッチ文字列。
  • ignoreCase:<boolean> 大文字小文字を無視する。
  • return:<boolean>
insert

文字列を挿入する。

  • seg:<string> 挿入する文字列。
  • pos:<number> 挿入位置。
  • return:<string>
repeat

文字列を繰り返す。

  • count:<number> 繰り返し回数。
  • return:<string>
sQuot

「'」で囲む。

  • return:<string>
startsWith

先頭にマッチする。

  • seg:<string> マッチ文字列。
  • ignoreCase:<boolean> 大文字小文字を無視する。
  • return:<boolean>

SimplePM.js

テキストと実行コマンドのみからなる単純なPopupMenu。

メニューの定義
  • text:<string> メニューのテキスト。
  • command:<Function||Array>
    • Function:メニュー選択時に実行する関数。
    • Array:サブメニュー。空の配列の場合、区切りとなる。

e.g.

var menu=[
	["a",function(){Alert("a");}],	//関数を実行する
	[],	//区切り
	["b",[
		["b-a",function(){return ["b","a"];}],	//配列を返す
		["b-c","b-c"]	//文字列を返す
	]]
]
var p=new SimplePM();
p.create(menu);
p.track();

メソッド

create

メニューを作成。

  • menu:<Array> メニュー定義の配列。
  • returnPopupMenu:<boolean> true:PopupMenuを返す、*false:自身を返す。
  • return:<PopupMenu||PPM>
getCommand

IDの項目のコマンドを返す。

  • id:<number> ID。
  • return:<*> 未定義の場合はテキストを返す。
getIdFromPosition

メニューの位置からIDを取得。

  • pos:<string> 位置。0起点で、上位の階層とは「-」で繋ぐ。
  • return:<number||undefined>

e.g.(冒頭の続き)

p.getText(p.getIdFromPosition("2-1"));	//"b-c"
getResult

前回の実行結果を返す。

  • return:<Object{id,result}> trackを参照。
getText

IDの項目のテキストを返す。

  • id:<number> ID。
modify

メニューの一部を変更する。

  • id:<number> アイテムのID。
  • @item:<command> 置き換えるメニューの定義。

e.g.(冒頭の続き)

p.modify(p.getIdFromPosition("2-1"),menu[0]);
track

メニューを表示、コマンドを実行。
コマンドが関数・配列でない場合はその値を返す。関数・配列を返したい場合は関数内でreturnする。

  • pos:<number> *0:カーソル位置に表示、1:キャレット位置に表示。
  • returnId:<boolean> コマンド未定義の場合の返り値。true:ID、*false:メニューのテキスト。
  • return:<Object{id,result}>
    • id:<number> ID。キャンセルした場合は0。
    • result:<*> 関数の返り値、コマンドの内容、もしくは@returnIdに従う。
スポンサーリンク