Author Topic: Caret options in CSED  (Read 11687 times)

0 Members and 1 Guest are viewing this topic.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Caret options in CSED
« on: March 15, 2014, 05:07:52 PM »
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 ? 

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Caret options in CSED
« Reply #1 on: March 15, 2014, 05:27:47 PM »
Sorry, but I don't know of any option that allows to do it.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #2 on: March 15, 2014, 07:01:53 PM »
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

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Caret options in CSED
« Reply #3 on: March 15, 2014, 07:26:31 PM »
I have read it, but I don't understand what they mean.
« Last Edit: March 15, 2014, 09:08:43 PM by José Roca »

Offline Paul Squires

  • Jr. Member
  • **
  • Posts: 90
  • User-Rate: +11/-5
    • PlanetSquires
Re: Caret options in CSED
« Reply #4 on: March 15, 2014, 07:48:24 PM »
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

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Caret options in CSED
« Reply #5 on: March 15, 2014, 09:08:31 PM »
It's a matter of habit. I also disliked it at first, but now what I dislike is the opposite.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #6 on: March 15, 2014, 09:55:39 PM »
"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


Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • User-Rate: +30/-4
    • it-berater
Re: Caret options in CSED
« Reply #7 on: March 15, 2014, 11:04:47 PM »
Get the cursor-keys before Scintilla gets them. Process them yourself.
Thats should do the Job.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #8 on: March 16, 2014, 06:26:25 PM »
Yep, some good old subclassing should do it. I´m going to give it a try in the next weeks


JK

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #9 on: March 17, 2014, 10:45:56 PM »
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



Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • User-Rate: +30/-4
    • it-berater
Re: Caret options in CSED
« Reply #10 on: March 22, 2014, 09:14:33 AM »
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.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #11 on: April 02, 2014, 08:40:53 PM »
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

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #12 on: April 11, 2014, 01:12:44 PM »
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
 

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Caret options in CSED
« Reply #13 on: April 11, 2014, 04:45:35 PM »
The CSED_OpenFile functio (in CSED_File.inc) calls

Code: [Select]
   ' // 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:

Code: [Select]
   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.

Offline Juergen Kuehlwein

  • Full Member
  • ***
  • Posts: 129
  • User-Rate: +0/-0
Re: Caret options in CSED
« Reply #14 on: April 11, 2014, 05:07:40 PM »
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