Hypertext and URLs

General TRichView support forum. Please post your questions here
Post Reply
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Hypertext and URLs

Post by martindholmes »

Hi there,

I'm writing an editor that has to support hypertext links, but I can't use AllTagsArePChars because I'm using tags for other purposes elsewhere in the code. So I'm looking for advice on the best method of storing and retrieving the URLs associated with hypertext links, using the item tags.

One option is to store the URLs in a StringList as name-value pairs, with some arbitrary number generated for each item:

123456=http://hotpot.uvic.ca/
234567=http://www.halfbakedsoftware.com/

and then retrieve them like this:

URLList.Values[IntToStr(MyRichView.GetItemTag(ItemNo))]

I'd have to ensure the tag values were all unique, of course. Does this seem like a reasonable approach? Has anyone else faced this problem and found a better solution?

All help appreciated,
Martin
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Since tags may be strings, you can encode any information in them.
For example, tags may be strings like:

Code: Select all

url="http://hotpot.uvic.ca/" mydata=15 yes=no
(tags must not contain line break and #0 characters, other characters are allowed)
You need to modify you code in OnReadHyperlink, OnWriteHyperlink and OnJump event to work only with "url" part of tags
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

That's a point; I guess I could set AllTagsArePChars and store my integers in the strings too. It'll slow down some other processing which uses integer tags, though.

Have you thought about adding a WideString field to every item by default? It would be SO handy to have a WideString and an integer tag as well.

Cheers,
Martin
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am afraid that integer/string switch is already too complicated solution.
If I add more options, such as widesting or objects, it would be even more complicated and hard to learn for novices.
Post Reply