C&T p.319 lastLineRange/1, if anybody wants it .....
Michael Turner
leap@REDACTED
Wed Mar 10 14:52:44 CET 2010
Thanks, Angel, but Text is, in this case a wxTextCtrl, not a string.
I went with the following, which seems to be doing the trick so far:
lastLineRange(T) ->
{ wxTextCtrl:xYToPosition(T,0,wxTextCtrl:getNumberOfLines(T)-1),
wxTextCtrl:getLastPosition (T) }
-michael turner
On 3/10/2010, "Angel" <clist@REDACTED> wrote:
>On Martes, 9 de Marzo de 2010 14:53:23 Michael Turner escribi坦:
>> I'm trying to work through the wx example in Cesarini & Thompson
>> (chapter "GUI programming with wxErlang". On p.319 there are two
>> calls to a function lastLineRange on a wx TextCtrl. The authors don't
>> supply this function, and I can't see any corresponding C++ member
>> function in the wxTextCtrl API here
>>
>> http://docs.wxwidgets.org/trunk/classwx_text_ctrl.html
>>
>> It's looking like I have to write lastLineRange myself, to finish
>> working through this chapter. Unless ... someone else has already run
>> into this roadblock, got around it, and can map out the detour for me?
>> I'm sure I'll kludge something up, but it would be nice to do this one
>> more or less by the book, if possible.
>>
>> -michael turner
>>
>>
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>lastLineRange seems to be a local function, not a wxwidgets one, maybe they
>didnt want to use undo facilities for the text control... (too complicated for
>a example)
>
>a quick fix (not tested) for this can be:
>
>LastLineRange(Text) ->
> ListOfLines=string:tokens(Text,[[10]]), %% Tokenize buffer on newlines
> LastLine=lists:last(ListOfLines), %% find the last line
> StarPos= wxTextCtrl:getlastposition() - length(LastLine),
> EndPos = wxTextCtrl:getlastposition,
> {StarPos,EndPos}
>
>
>Maybe it just works, YMMV
>
>/angel
>
>
>Most people know C is not so high level....
> ...Everybody else just got assembler overdose
>
>
>________________________________________________________________
>erlang-questions (at) erlang.org mailing list.
>See http://www.erlang.org/faq.html
>To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list