[erlang-questions] Re: C&T p.319 lastLineRange/1, if anybody wants it .....

Angel clist@REDACTED
Thu Mar 11 23:22:08 CET 2010


My fault!!

Yeahh i didnt bother to read p 318 where is clear that Text is a control.. :-(

I tried to understand the undo mechanism so i forgot completly about the
subject...

Thanks!

On Miércoles, 10 de Marzo de 2010 14:52:44 Michael Turner escribió:
> 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
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 

Most people know C is not so high level....
                ...Everybody else just got assembler overdose
 


More information about the erlang-questions mailing list