• Welcome to Jose's Read Only Forum 2023.
 

Caret options in CSED

Started by Juergen Kuehlwein, March 15, 2014, 05:07:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Juergen Kuehlwein

I would like the caret to behave just like in PB´s IDE i.e. not to jump to the next/previous line if i go beyond the (current) end/start of a line using (horizontal) cursor keys. In other words, i don´t want the caret to go to a different line on "right"-key or "left"-key. "CSED_SetScintillaOptions" in "CSED_SCI.inc" seems a good place, i think, but how to do it ? 

José Roca

Sorry, but I don't know of any option that allows to do it.

Juergen Kuehlwein

SCI_SETCARETSTICKY(int useCaretStickyBehaviour)
SCI_GETCARETSTICKY
SCI_TOGGLECARETSTICKY
These messages set, get or toggle the caretSticky setting which controls when the last position of the caret on the line is saved.

When set to SC_CARETSTICKY_OFF (0), the sticky flag is off; all text changes (and all caret position changes) will remember the caret's new horizontal position when moving to different lines. This is the default.

When set to SC_CARETSTICKY_ON (1), the sticky flag is on, and the only thing which will cause the editor to remember the horizontal caret position is moving the caret with mouse or keyboard (left/right arrow keys, home/end keys, etc).

When set to SC_CARETSTICKY_WHITESPACE (2), the caret acts like mode 0 (sticky off) except under one special case; when space or tab characters are inserted. (Including pasting only space/tabs -- undo, redo, etc. do not exhibit this behaviour..).

SCI_TOGGLECARETSTICKY switches from SC_CARETSTICKY_ON and SC_CARETSTICKY_WHITESPACE to SC_CARETSTICKY_OFF and from SC_CARETSTICKY_OFF to SC_CARETSTICKY_ON.


This is from scintilla docs and seems to do what i want (?)

I tried:

      CSED_SetScintillaOptions(pSed.hEdit, PathName$(Extn, strPath))
      sendmessage pSed.hEdit, %SCI_SETCARETSTICKY, 0, 0
      sendmessage pSed.hEdit, %SCI_TOGGLECARETSTICKY, 0, 0     

(and variations of it) in "SED_CreateMdiChild" to no (expected) result, it fact it doesn´t change anything - wrong implementation of these %SCI_ ... messages or a misconception what "sticky caret" really means?


If there is no option for such behaviour in scintila, this would be very bad news to me, because i don´t like this standard windows edit control "feature" of jumping to the next/previous line at all.

What about adding spaces to each line up to PB´s line lenght limit, this makes the caret do what i want, but i would get a bunch of different problems ...  Hmm, got to think about it.


Thanks anyway José - extremly nice work !


JK

José Roca

#3
I have read it, but I don't understand what they mean.

Paul Squires

I don't think that the CARETSTICKY commands are what you need to solve the problem. I also do not like the wrapping to previous line end when going past the home position. I have yet to find a way in Scintilla to prevent it. The CodeBlocks editor also suffers from this and there is no setting to prevent the behaviour (that I can find).
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

José Roca

It's a matter of habit. I also disliked it at first, but now what I dislike is the opposite.

Juergen Kuehlwein

"It's a matter of habit"

Yes, but i have never been able to get used to it the last 20 years - no matter how hard i tried ...
Well, maybe i find a way to get what i want and if so i´m going to post  a snippet here.


JK


Theo Gottwald

Get the cursor-keys before Scintilla gets them. Process them yourself.
Thats should do the Job.

Juergen Kuehlwein

Yep, some good old subclassing should do it. I´m going to give it a try in the next weeks


JK

Juergen Kuehlwein

Subclassing works as expected, bur there stil are some quirks to overcome. If i fill a line with blanks, indentation lines are shown all over the line, even if this line is all blanks (spaces). How could i avoid this (i want indentation lines to be shown, but not in lines of blanks without any other text).

Is there a general styling option for blank lines, or do i have to style such a line individually and how to do it - this is beyond my current scope.

Maybe SCI_ADDSTYLEDTEXT would be an option, but how to setup these "cells" to not show indentation lines ?


JK



Theo Gottwald

I am not sure you are doing the right thing, Jürgen.
The Syntax coloring should not be of importance here.
Suggestion: Study the possibilities of the Control a bit. This will make things a lot easier.

Juergen Kuehlwein

This s what i currently have:

I subclass Scintilla (newsciproc in JK_CSED.bas) and everytime the caret goes to a postion, where no characters are, spaces are added, so it can go there. It is a workaround but seems to do what i want.

Syntax coloring doesnt´t work in all cases (e.g ASM code and other things, folding points are set according to indentation which is not always nice (continuing lines, comments etc.). Indentation guides cannot be set to look nice in all cases either. So i decided to write a new lexer for PowerBasic and .rc files, a special indentation guide mode (SC_IV_PB) and some other additions and minor changes (if an entire line is selected, this line is marked to the right side of the screen, folding points have three differnt color now) for Scintilla.

This was done with VC++ 2010 based on Scintilla 3.39, CSED files have been renamed to JK_CSED... in order not to get mixed up with Gary´s version, which i use as a starting point.

The compiled CSED_JK.exe can be found in CSED\Scintilla\Win32\Release. This is where "Scilexer.dll" is compiled to as well.

You must outcomment "DECLARE FUNCTION Scintilla_DirectFunction...." in José´s includes (Scintilla.inc), because VC++ 2010 names it ""_Scintilla_DirectFunction@16" as declared in "JK_CSED.bas", if you want to recomile with PB.

Please ask, if you need help with it and report bugs (this is still work in progress).


JK

Juergen Kuehlwein

Hi José,


sorry for bothering you, but where in your code  (i´ve been searching around for almost an hour and i cannot find it) do you set the name of the current file into the caption ? "$CSEDCAPTION" is used as a prefix, but where do you add "- [" + <filename> + "]" ??


Thanks,


JK

José Roca

The CSED_OpenFile functio (in CSED_File.inc) calls


   ' // Create a new MDI child window
   hMdi = CSED_CreateMdiChild(strFileName)


and the CSED_CreateMdiChild (in CSED.BAS), created a new MDI child window using that path:


   hMdi = CreateMdiChild("PBFrameClass", pSed.hwndClient, BYCOPY strPath, IIF&(pSed.MaximizeEditWindows = %BST_CHECKED, %WS_MAXIMIZE, 0))


BTW $CSEDCAPTION IS NOT used as a prefix, but as the caption of the amain window.

Run the edit in MDI mode (unchecking the "Maximize edit windows" option) and you will see the difference.

Juergen Kuehlwein

Thanks for your quick reply,


stupid me, you don´t add it anywhere or course! It´s the mdi client, if childs are shown maximized...


JK