我使用的是Gtk2Hs,所有這些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
秒。但是我一直沒有找到任何功能來從TextMark中獲得一個 TextIter。這是正確的程序嗎?