Detecting whether a style is hypertext

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

Detecting whether a style is hypertext

Post by martindholmes »

Hi there,

I have a very odd problem. I'm trying to detect whether the current item has a hypertext (jump) style, and if so, I want to select all of its text. This is the code I'm using (rveSnippets is the TRichViewEdit, and rvsSnippets is the associated TRVStyle):

CurrItem := rveSnippets.CurItemNo;

StyleNo := rveSnippets.CurItemStyle;

if rvsSnippets.TextStyles[StyleNo].Jump then
//we have an existing link
begin
//Select the entire item
rveSnippets.SetSelectionBounds(CurrItem, 0, CurrItem, 1);
rveSnippets.Invalidate;
end;

The problem is that the code does nothing: in fact, I'm pretty sure it's completely eliminated by the linker, because setting a breakpoint on any of these lines gives me the green breakpoint-with-a-cross symbol that means it'll never break. Can anyone suggest why, or what I'm doing wrong?

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

Post by Sergey Tkachenko »

Offsets in text items start from 1 (before the first character), and offset after the last character is Length+1.

Code: Select all

CurrItem := rveSnippets.TopLevelEditor.CurItemNo; 
StyleNo := rveSnippets.TopLevelEditor.CurItemStyle; 

if (StyleNo>=0) and rvsSnippets.TextStyles[StyleNo].Jump then 
//we have an existing link 
begin 
  //Select the entire item 
  rveSnippets.TopLevelEditor.SetSelectionBounds(CurrItem, 1, CurrItem,  rveSnippets.TopLevelEditor.GetOffsAfterItem(CurrItem)); 
  rveSnippets.TopLevelEditor.Invalidate; 
end; 
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

Thanks Sergey!

Cheers,
Martin
Post Reply