私は Gtk2H を使用していますが、この GTK はすべて初めてのことです。私はで働いていTextView
ます。現在選択されているテキストを新しいテキストに置き換え、新しいテキストを選択したいと考えています。私が思いついた最も近いものは次のとおりです。
-- Create marks so I can "remember" where the selection was
(startIter, stopIter) <- textBufferGetSelectionBounds buffer
startMark <- textBufferCreateMark buffer (Just "start") startIter True
stopMark <- textBufferCreateMark buffer (Just "stop") stopIter True
-- Delete the currently selected text
textBufferDeleteSelection buffer True True
-- now startIter and stopIter are no longer valid
-- Insert the new text
somehow convert startMark to startIter2 ???
textBufferInsert buffer startIter2 text
-- now startIter2 is no longer valid
-- Select the new text
somehow convert startMark to startIter3 ???
somehow convert stopMark to stopIter3 ???
textBufferSelectRange buffer startIter3 stopIter3
選択を設定するために私が見つけた唯一の関数は、TextIter
sではなくTextMark
sを必要とします。しかし、TextMark から TextIter を取得する関数を見つけることができませんでした。これは正しい手順ですか?