deindent in scintilla

Just starting out? Need help? Post your questions and find answers here.
TRS-Eric
User
User
Posts: 16
Joined: Thu Apr 23, 2020 7:42 pm

deindent in scintilla

Post by TRS-Eric »

I've just noticed I can no longer de-indent in Scintilla. I'm pretty sure it used to work.

Tab works to indent but shift-tab does not de-indent. It seems to just go to another gadget. At one time I removed the keyboard shortcut for tab and in a comment I wrote that it fixed indenting, but yeah it's not working now, the behavior is the exact same whether the keyboard shortcuts are enabled or disabled on the window.

I tried this on the latest 6.21 Beta 9 as well as 6.12 which I was using until I started bughunting this issue.

Code: Select all

EnableExplicit

#Scintilla = 0
#Button = 1

If OpenWindow(0, 0, 0, 600, 400, "Scintilla Shift+Tab Issue", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(#Button, 10,10,100,95, "Button")
  ScintillaGadget(#Scintilla, 10, 100, 580, 380, 0)
  ;RemoveKeyboardShortcut(0, #PB_Shortcut_Tab)
  ;RemoveKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_Tab)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
---
BASIC related discord: https://discord.gg/KS4en5y5j4
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: deindent in scintilla

Post by AZJIO »

I think it doesn't work out of the box. If you enter a character, it is deleted using Backspace. If you want to use Shift+Tab, then you need to write a function.
I may be mistaken, since Tab does not work as a character for several lines, but as an indentation insertion.

Code: Select all

EnableExplicit

#mBackTab = 0
#Scintilla = 0
#Button = 1

Define *Text

If OpenWindow(0, 0, 0, 600, 400, "Click on the button", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	ButtonGadget(#Button, 10,10,100,33, "Button")
	ScintillaGadget(#Scintilla, 10, 100,380, 380, 0)
	*Text=UTF8(#TAB$ + #TAB$ + "Line1" + #CRLF$ + #TAB$ + #TAB$ + "Line2" + #CRLF$ + #TAB$ + #TAB$ + "Line3")
	ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
	FreeMemory(*Text) 
	ScintillaSendMessage(#Scintilla, #SCI_SELECTALL, 0, 0)
	AddKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_Tab, #mBackTab)
	
	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Menu 
				Select EventGadget()
					Case #mBackTab
						ScintillaSendMessage(#Scintilla, #SCI_BACKTAB, 0, 0)
				EndSelect
			Case #PB_Event_Gadget
				Select EventGadget()
					Case 1
						ScintillaSendMessage(#Scintilla, #SCI_BACKTAB, 0, 0)
				EndSelect
			Case #PB_Event_CloseWindow
				CloseWindow(0)
				End
		EndSelect
	ForEver
EndIf
TRS-Eric
User
User
Posts: 16
Joined: Thu Apr 23, 2020 7:42 pm

Re: deindent in scintilla

Post by TRS-Eric »

Yes that works, thanks!

It's strange that the default behavior accepts tab but not backtab, but this works for me!
---
BASIC related discord: https://discord.gg/KS4en5y5j4
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: deindent in scintilla

Post by Fred »

I tried with 5.73 and it's the same behaviour.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: deindent in scintilla

Post by moricode »

it is working fine in 5.72 TAB indent / shift TAB back indent
Post Reply