Alternate for Richedit

Working on new editor enhancements?
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Just downloaded your last code.
Hope I will have some time, and grasp how you did it.
Thanks for the learning stuff :wink:

BTW: The Line Number Margin is not working well.

bye
Franco
always :?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

>BTW: The Line Number Margin is not working well.

I had activate a folding Flag, that will show the Foldlevel in the Line Number Margin.

Change this line:
SCI_SetFoldFlags(16+64)

to
SCI_SetFoldFlags(16)

GPI
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

sweet :!:
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Found a way to protect the fold from changing.

Only one problem.

Mark a larger text. Press Cntrl+C
Mark a text over a closed fold.
now Press Ctrl+V

no text is now deleted, but the Text is insert.

I think, with this i can live :)

http://caosandkin.bei.t-online.de/purebasic/fold2.zip
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Hi GPI, I try to insert the Calltips into the latest code you provided, but it works only once.
First I created a data for CallTips (not complete though) and Restored it like you did with the other 2 data (ASM and KeyWord)

Code: Select all

  CallTips:
  ;not complete, for testing only...
    Data$ "Abs (Number.f) - Returns the Absolute value (no sign) of the given float valueee. - Result.f = Abs(Number.f)"
    Data$ "ACos (Value.f) - Returns the Arc-Cosinus of the specified value. - Result.f = ACos(Value.f)"
    Data$ "ActivateGadget (#Gadget) - Set the focus on the specified Gadget"
    Data$ "ActivatePopUpWindow (#PopUpWindowIndex) - Activate (set focus to) the specified Pop-up window."
    Data$ "ActivateWindow () - Activate the current window, this means than focus has been put on this window."
    Data$ ""

I use the same buffer you use in your SetStyle procedure.
I changed in the procedure:

Code: Select all

...
          Case #Style_Procedure
            If Find_Proc(*Word)
              If CompareMemoryString(*Word,@Proc()\s,0)
                ReplaceSCIText(start,start+WordLen,@Proc()\s,#False)
              EndIf
            Endif
to:

Code: Select all

          Case #Style_Procedure
            If Find_Proc(*Word)
              If CompareMemoryString(*Word,@Proc()\s,0)
                ReplaceSCIText(start,start+WordLen,@Proc()\s,#False)
              EndIf
            Else
              CallTipText(Start,start+WordLen+1,*Word)
            EndIf
and my CallTipText Procedure looks like:

Code: Select all

Procedure CallTipText(StartPos,EndPos,buffer)
  
  If buffer>0
    Length.l = Len(PeekS(buffer))
    CallTipBuffer.l = AllocateMemory(10,Length)
    SCI_GotoPos(StartPos)
    SCI_GetText(EndPos,CallTipBuffer)
    
    For i = 0 To MaxCallTips  ;MaxCallTips is Global
      Length.l = Len(PeekS(CallTipBuffer))
        
      If Right(PeekS(CallTipBuffer),EndPos-StartPos-1) = Left(PeekS(@CallTips(i)\s),Length)
        CompareMemoryString(CallTipBuffer,@Left(PeekS(@CallTips(i)\s),Length),0)
        SCI_CallTipShow(StartPos,@CallTips(i)\s)
      EndIf
    Next
    
    SCI_GotoPos(EndPos)
    FreeMemory(10)
  EndIf
  
EndProcedure
but as I said it works only once.
What I don't get is why my CallTipBuffer holds all words found (so does your buffer too) instead only the last one...
Even if I do a FreeMemory all the time.

Maybe I misunderstood your code (for sure!).

What I noticed is, that your code learns everytime when I create a new Procedure...
Maybe I can't put my Calltip code into the "Case #Style_Procedure" :?:

BTW: the command Str is twice in the list (ASM and Pure). Only the Str from Pure is valid while typing, but not the ASM one.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Yes, you misunderstand some things.

first of all:
SetStyle is a subroutine of coloring line and this line must not the active one, so it isn't a good method to find the word here.

Find_Proc/Struc/etc. Search the word in the list and yes, the list is updating while tipping text. (These does the Find_Term routines in combination with notifiy-messages insert/deleteText and beforeinsert/Delete (see windowcallback).

How would i do this:
I would wait until the Cursor moves out of a word.
Look in the Window-Callback-procedure and the notify-message
#SCN_UPDATEUI

Code: Select all

              If (WordUnderCursorPos>Pos Or Pos>WordUnderCursorEnd)
                WordUnderCursorPos=Pos:WordUnderCursorEnd=Pos ; also coloring, when the cursor moves out the word
                Find_NewTerm(1,line,0,0)
                UpdateList(#False)                
                ColoringLine(#True,-1,line)                 ; because word under cursor doesn't colored!
              EndIf
Here is a check, it the Cursor is moved out of a word. When the Cursor is in a word, it is never colored right (i use the style of the first char in the Word) and is never replaced. So you can type endPOS, without that the editor change end to End.

WordUnderCursorPos and WordUnderCursorEnd show the beginn and end of the word and WordUnderCursorType holds the #style_xyz.

This position is perfekt to check, if a tooltip should appear.

Some additionals:
I have in the ListInfo-Structure a Add-Type. I planed to used this add to store addition informations, like Tool-Tip-String-Adress.

There are checks, that this Words never earsed out of the list and are always in. But this check only check the first byte.
so search all \add (not more, because i had maybe add spaces), and replace all "& 1=0" with "=0" and "&1" with "".

Now you can store in the \add variable a adress to the string with the tooltip.

To add this, do something like this

Code: Select all

structure string
  s.s
endstructure
newlist tooltip.string()

Proc$="Abs":Tooltip$="Abs (Number.f) - Returns the Absolute value (no sign) of the given float valueee. - Result.f = Abs(Number.f)"
if find_proc(proc$)=0
  ; word not found, and here is a good insert position (because the list is alphabetic and the find_ set a good position to insert proc$)
  addelement(proc())
  proc()\s=proc$
;else
;  already in the list, but now we insert a tooltip
endif
addelement tooltip()
tooltip()\s=tooltip$
proc()\add=@tooltip()\s ; structure here, because @tooltip$() will not show the right adress, it will give you the adress to the element thing.
Another Tip: If you don't want to add a tooltip, but you want to add a name to the list and this name should never earesed, then set \add to 1 (because a tooltip can never set to this adress). But you should test before writing the tooltip, that the adress<>1 or your code will crash.

P.S.: A save the LIst (proc/struc/etc) in memory while switch between the sourecodes and so the switch is fast as in the editor. Your version will allways recreate the complete list, when you switch the code and this can be very slow.
p.p.s.: The compiler creates automatic a list with all definited functions and there tooltip. Look in the original code of the editor.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Thanks GPI,
I will got through your comments and suggestions.

Franco
always :?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

>always :?

Ok, had today time: Here my ToolTip-Solution. Ok, i don't use tooltip, i used a Info-Box, where you can see the last 10 messages. There will be all error-messages, Infos, etc.

I hate in the original editor, when i get the info of a function and then i type GadgetId() and the tip is gone...

http://caosandkin.bei.t-online.de/purebasic/ToolTip.zip


But remove a little bug

change this (in then callback)

Code: Select all

          Case #SCN_UPDATEUI
            Pos=SCI_GetCurrentPos()
            line=SCI_LineFromPosition(Pos)
            If line<>Callback_OldLine
to this

Code: Select all

          Case #SCN_UPDATEUI
            Pos=SCI_GetCurrentPos()
            line=SCI_LineFromPosition(Pos)
            If line<>Callback_OldLine
              WordUnderCursorPos=Pos:WordUnderCursorEnd=Pos
(the last line is added).

The Editor-Functions are not shown in the Proc-List.

The function to add a tooltip in a new tipped word find you in the setStyle() and the tooltip of a cursor-leave-word (You get a tooltip, when you move in a word and move out left/right) find you in the windowCallback in the #scn_updateui.

Some note: Some PB-Functions have no Tip, like Chr(), AddElement().

GPI
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

I've tried to compile folding example2 but there's a missed constant #SCLEX_Container
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

You have a older scintilla.pbi

#SCLEX_CONTAINER = 0
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Ok, i have now test SciTe for PB (I love Shortcuts :) and so i change my ToolTip-Functions.

I show now between the Editor-Gadget and the Message-Box a Tooltip-Line. There are the Tooltip for the actual procedure and there are also mark the right parameter, where the cursor is in.
Also
OpenWindow(asc(A$),asdf)
is handle correct. When you close asc( with ), the ToolTip-Line change to openWindow.

Why i not use the Scintella-Tooltip?
Simple: It is impossible to use the Scintella-Tooltip and the Auto-Completion from Scintella at the same time. I think my methode is a good solution for this problem.

Also, what is new: I defined all the PB-Constant and definied ToolTips, where the Editor don't give one.

The Definition file is in the "Definitions"-Directory and is called "PureBasic.TXT" and is a simple Textfile. In the Future will there all Files read in, but in the moment only the PureBasic.TXT is read in.

GPI

p.s.:i forget to answer, why ADD (Asm-Command) is not marked right. Use !ADD or change the InlineASM-Variable.

EDIT:
The Downloadlink: http://caosandkin.bei.t-online.de/pureb ... olTip2.zip
Post Reply