#1096 Call Tip Up Down Arrows not working

Bug
closed-works-for-me
Scintilla (792)
5
2011-02-16
2011-02-08
No

I incorporated Scintilla Version 2.24 into my project two days ago. I was previously using version 1.78. My project has been using Scintilla for about 2 years with no bugs. When I upgraded two days ago to version 2.24 I found this one bug. I spent all day yesterday and found a solution to the bug. I hope my solution helps.

In the file src/CallTip.cxx inside the function CallTip::PaintContents I first added

int valLength = (int)strlen(val) ;

before the while loop. Then inside the while loop I changed the code to:

if (thisStartHighlight < valLength)
{
DrawChunk(surfaceWindow, x, chunkVal, 0, thisStartHighlight,
ytext, rcClient, false, draw);
}
if (thisStartHighlight < valLength)
{
DrawChunk(surfaceWindow, x, chunkVal, thisStartHighlight, thisEndHighlight,
ytext, rcClient, true, draw);
}
if (thisEndHighlight < valLength)
{
DrawChunk(surfaceWindow, x, chunkVal, thisEndHighlight, chunkLength,
ytext, rcClient, false, draw);
}

Basically as you can see I added an if wrapper around each DrawChunk to make sure the highlight zone is actually inside the given call tip string.

If I find any more bugs I will let you know. But, so far, this is the only bug I have encountered.

Discussion

  • Derby Russell

    Derby Russell - 2011-02-08

    Here is the file as I repaired it.

     
  • Derby Russell

    Derby Russell - 2011-02-08

    Just discovered more. The repair I describe here only works in Debug mode. I cannot figure out why. But, I did find a better solution, that works in both Debug and Release. First, do not make any changes listed above!

    Do this instead:

    in the function CallTip::DrawChunk
    before the for loops add the following line:
    int valLength = (int)strlen(val) ;

    then in the lower for loop change the following code from:

    if (upArrow) {
    rectUp = rcClient;
    } else {
    rectDown = rcClient;
    }

    to:

    if (posStart < valLength)
    {
    if (upArrow) {
    rectUp = rcClient;
    } else {
    rectDown = rcClient;
    }
    }

    this is a more solid fix anyway.

     
  • Neil Hodgson

    Neil Hodgson - 2011-02-08

    I can not reproduce this bug. I do not understand what you mean by "Up Down Arrows not working". In SciTE, using the following text in a .api file results in a calltip with working up and down arrows after typing fread(:

    fread(FObject &fp)
    fread(void* buf, size_t size, size_t count, FILE* file)

    I do not understand why your patch works for you.

     
  • Neil Hodgson

    Neil Hodgson - 2011-02-08
    • assigned_to: nobody --> nyamatongwe
    • status: open --> open-works-for-me
     
  • Neil Hodgson

    Neil Hodgson - 2011-02-09

    There are no significant changes in CallTip.cxx/CallTip.h since version 1.78. Here are the changes which are ensuring initialization, making methods const, removing unused checks in memory allocation, omitting unused method bodies, and layout.

    >hg diff -r rel-1-78 CallTip.*
    diff -r a313740fe8b8 src/CallTip.cxx
    --- a/src/CallTip.cxx Mon Apr 27 03:34:45 2009 +0000
    +++ b/src/CallTip.cxx Wed Feb 09 11:18:00 2011 +1100
    @@ -29,6 +29,7 @@
    rectUp = PRectangle(0,0,0,0);
    rectDown = PRectangle(0,0,0,0);
    lineHeight = 1;
    + offsetMain = 0;
    startHighlight = 0;
    endHighlight = 0;
    tabSize = 0;
    @@ -45,6 +46,8 @@
    colourSel.desired = ColourDesired(0, 0, 0x80);
    colourShade.desired = ColourDesired(0, 0, 0);
    colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
    + codePage = 0;
    + clickPlace = 0;
    }

    CallTip::~CallTip() {
    @@ -68,7 +71,7 @@
    }

    // We ignore tabs unless a tab width has been set.
    -bool CallTip::IsTabCharacter(char ch) {
    +bool CallTip::IsTabCharacter(char ch) const {
    return (tabSize > 0) && (ch == '\t');
    }

    @@ -95,7 +98,7 @@
    int maxEnd = 0;
    const int numEnds = 10;
    int ends[numEnds + 2];
    - for (int i=0;i<len;i++) {
    + for (int i=0; i<len; i++) {
    if ((maxEnd < numEnds) &&
    (IsArrowCharacter(s[i]) || IsTabCharacter(s[i])) ) {
    if (i > 0)
    @@ -254,11 +257,9 @@
    const char *faceName, int size,
    int codePage_, int characterSet, Window &wParent) {
    clickPlace = 0;
    - if (val)
    - delete []val;
    + delete []val;
    + val = 0;
    val = new char[strlen(defn) + 1];
    - if (!val)
    - return PRectangle();
    strcpy(val, defn);
    codePage = codePage_;
    Surface *surfaceMeasure = Surface::Allocate();
    diff -r a313740fe8b8 src/CallTip.h
    --- a/src/CallTip.h Mon Apr 27 03:34:45 2009 +0000
    +++ b/src/CallTip.h Wed Feb 09 11:18:00 2011 +1100
    @@ -27,13 +27,13 @@
    bool useStyleCallTip; // if true, STYLE_CALLTIP should be used

    // Private so CallTip objects can not be copied
    

    - CallTip(const CallTip &) {}
    - CallTip &operator=(const CallTip &) { return *this; }
    + CallTip(const CallTip &);
    + CallTip &operator=(const CallTip &);
    void DrawChunk(Surface *surface, int &x, const char *s,
    int posStart, int posEnd, int ytext, PRectangle rcClient,
    bool highlight, bool draw);
    int PaintContents(Surface *surfaceWindow, bool draw);
    - bool IsTabCharacter(char c);
    + bool IsTabCharacter(char c) const;
    int NextTabPos(int x);

    public:
    @@ -61,7 +61,7 @@

    /// Setup the calltip and return a rectangle of the area required.
    PRectangle CallTipStart\(int pos, Point pt, const char \*defn,
    

    - const char *faceName, int size, int codePage_,
    + const char *faceName, int size, int codePage_,
    int characterSet, Window &wParent);

    void CallTipCancel\(\);
    
     
  • Derby Russell

    Derby Russell - 2011-02-09

    Did you read my "Just discovered more" comment below? The original post repair code is completely useless

     
  • Derby Russell

    Derby Russell - 2011-02-09

    When I debug the code My program gets the SCN_CALLTIPCLICK notification message but the SCNotification position member is always 0. By changing the call tip code to:

    int valLength = (int)strlen(val) ;

    if (posStart < valLength)
    {
    if (upArrow) {
    rectUp = rcClient;
    } else {
    rectDown = rcClient;
    }
    }

    then the call tip arrows send the correct message.

    When I debugged the scintilla code I found that the rectUp and rectDown were being filled with improper values. The repair listed here fixed the problem.

     
  • Neil Hodgson

    Neil Hodgson - 2011-02-09

    I suspect you are passing invalid values into Scintilla. What sequence of calls is producing this?

     
  • Derby Russell

    Derby Russell - 2011-02-09

    I usually send something similar to this:

    SendMessage(hEditor, SCI_CALLTIPSHOW, (WPARAM) nCallWordStartPos, (LPARAM) "\001 1 of 3 \003 LoadString(arg, arg, arg, ...)") ;

    and then wait for SCN_CALLTIPCLICK which I always receive when the mouse is clicked over the call tip. It is just that the position returned with that notification is always zero now and before it was either 1 or 2

     
  • Derby Russell

    Derby Russell - 2011-02-09

    Sorry, I am manually typing in something that is automatically generated the text part of this message is currently not ever what I would send. I would never send the string shown. Here is what I usually send:

    SendMessage(hEditor, SCI_CALLTIPSHOW, (WPARAM) nCallWordStartPos, (LPARAM)
    "\001 1 of 3 \002 LoadString(arg, arg, arg, ...)") ;

    Never \003 but \002 oops sorry.

     
  • Derby Russell

    Derby Russell - 2011-02-09

    Here is an actual output from a debugging session earlier today:

    \001 1 of 3 \002 CHString::LoadStringW(UINT nID, LPWSTR lpszBuf, UINT nMaxBuf)

    without modifying the \001 and \002:

     1 of 3 CHString::LoadStringW(UINT nID, LPWSTR lpszBuf, UINT nMaxBuf)

     
  • Neil Hodgson

    Neil Hodgson - 2011-02-09

    That call works fine for me and can produce notifications for up and down arrows with 1 or 2 in the position field. Since your changes deal with the highlight, there should also be a call to SCI_CALLTIPSETHLT after the SCI_CALLTIPSHOW.

     
  • Derby Russell

    Derby Russell - 2011-02-09

    This could then be my problem. I am calling SCI_CALLTIPSETHLT only if I get SCN_UPDATEUI and if I do I call SCI_CALLTIPACTIVE if
    SCI_CALLTIPACTIVE returns true or 1 or TRUE I then call
    SCI_CALLTIPSETHLT.
    You are saying I need to call SCI_CALLTIPSETHLT immediately after calling SCI_CALLTIPSHOW. This could then be my problem.

     
  • Derby Russell

    Derby Russell - 2011-02-09

    Thank you for your help I will be trying this tomorrow.

     
  • Neil Hodgson

    Neil Hodgson - 2011-02-09

    If you don't call SCI_CALLTIPSETHLT then the highlight range is 0..0 which works fine for me.

     
  • Nobody/Anonymous

    Been trying to respond back for several days. Blocked by ATT Uverse (sourceforge). Using Blackberry. Also it was difficult getting here through all the bogus bug reports.

    But, anywho, just wanted you to know, SCI_CALLTIPHLT is required after a calltip is shown. Immediately after. Now my call tip arrows are working perfectly.

    This BUG entry is NOT A BUG.

     
  • Derby Russell

    Derby Russell - 2011-02-16

    Ok, I am not blocked by ATT Uverse right now. Back at desktop and logged in.

    You must send an SCI_CALLTIPHLT message right after the SCI_CALLTIPSHOW. Then the arrow will always work properly.

    Thank you and this is not a bug and can be closed and solved.

     
  • Derby Russell

    Derby Russell - 2011-02-16
    • status: open-works-for-me --> closed-works-for-me
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks