Page 1 of 1

Detecting whether a style is hypertext

Posted: Mon Mar 06, 2006 1:22 pm
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

Posted: Mon Mar 06, 2006 2:24 pm
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; 

Posted: Tue Mar 07, 2006 1:26 pm
by martindholmes
Thanks Sergey!

Cheers,
Martin