in reply to Re: Extracting information from a Text widget
in thread Extracting information from a Text widget

Well, I need to be able to add shapes into the text widget, say if the user right-clicks on the red circle (in the tree widget), and requests to duplicate the red circle 3 times. Could the hash design accomodate this?

The reason I was thinking of using the line.char references was so that I could insert the new circles in the correct place in the text (i.e. after the original red circle).

  • Comment on Re^2: Extracting information from a Text widget

Replies are listed 'Best First'.
Re^3: Extracting information from a Text widget
by aquarium (Curate) on Jul 08, 2007 at 22:37 UTC
    use a suitable linked list module, or there might be something similar under "sequence" in CPAN. this will help keep the design logic separate from implementation.
    as per your clarification, you're interested in being able to follow sequences. An artificial contrivance such as text box co-ordinates will surely slow you down in implementation, not to mention horrible maintenance. the basic idea is of sequences or linked lists or such. if you use text box co-ordinates, they'll need to be re-computed for shapes following an insert.
    all the best in your project
    the hardest line to type correctly is: stty erase ^H
Re^3: Extracting information from a Text widget
by BrowserUk (Patriarch) on Jul 03, 2007 at 18:19 UTC
    ... I was thinking of using the line.char references was so that I could insert the new circles in the correct place in the text ...

    Rather than fighting to translate character offsets to line/char offsets in order to insert the additions, why not query the entire text, perform substitutions on that and then replace (delete/insert) the entire text?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.