Я использую 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
с, не TextMark
с. Но я не смог найти какие-либо функции для получения текстового текста из TextMark. Это правильная процедура?