1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-26 17:10:38 +00:00

Improved cursor behavior when auto indent is off.

When auto indent is turned off in Options->Code Layout, hitting ENTER to create a new line will cause the cursor to be aligned with the previous line start, making it easier to manually indent code.

Also:
- Hitting backspace when there's no text before the cursor will also cause it to jump back following the tab spacing set in the Code Layout dialog.
This commit is contained in:
FellippeHeitor 2016-06-21 01:31:42 -03:00
parent f76ff5eb5b
commit 86f79d8b29
2 changed files with 42 additions and 8 deletions

View file

@ -3,5 +3,5 @@ DIM SHARED BuildNum AS STRING
Version$ = "1.000"
'BuildNum format is YYYYMMDD/id, where id is a ever-increasing
'integer. If you make a change, update the date and increase the id!
BuildNum$ = "20160614/19"
BuildNum$ = "20160621/20"

View file

@ -3058,14 +3058,28 @@ DO
IF K$ = CHR$(13) THEN
ideselect = 0
desiredcolumn = 1
idechangemade = 1
a$ = idegetline(idecy)
IF idecx > LEN(a$) THEN
ideinsline idecy + 1, ""
IF ideautoindent = 0 THEN desiredcolumn = LEN(a$) - LEN(LTRIM$(a$)) + 1
ELSE
idesetline idecy, LEFT$(a$, idecx - 1)
ideinsline idecy + 1, RIGHT$(a$, LEN(a$) - idecx + 1)
IF ideautoindent = 0 THEN
desiredcolumn = LEN(a$) - LEN(LTRIM$(a$))
new.a$ = idegetline(idecy)
IF LEN(LTRIM$(RTRIM$(new.a$))) = 0 THEN desiredcolumn = 0
ELSE
desiredcolumn = 0
END IF
ideinsline idecy + 1, SPACE$(desiredcolumn) + RIGHT$(a$, LEN(a$) - idecx + 1)
IF ideautoindent = 0 THEN
IF desiredcolumn = 0 THEN desiredcolumn = 1 ELSE desiredcolumn = desiredcolumn + 1
ELSE
desiredcolumn = 1
END IF
END IF
IF idecx = 1 THEN
@ -3075,7 +3089,7 @@ DO
END IF
idecy = idecy + 1
idecx = 1
idecx = desiredcolumn
GOTO specialchar
END IF
@ -3119,11 +3133,31 @@ DO
GOTO specialchar
END IF
IF idecx > LEN(a$) + 1 THEN
idecx = LEN(a$) + 1
IF LEN(LTRIM$(RTRIM$(a$))) > 0 THEN
idecx = LEN(a$) + 1
ELSE
GOTO CheckSpacesBehind
END IF
ELSE
a$ = LEFT$(a$, idecx - 2) + RIGHT$(a$, LEN(a$) - idecx + 1)
idesetline idecy, a$
idecx = idecx - 1
CheckSpacesBehind:
IF LEN(RTRIM$(MID$(a$, 1, idecx - 1))) = 0 AND ideautoindent = 0 THEN
'Only spaces behind. If we're on a tab stop, let's go back in tabs.
x = 4
IF ideautoindentsize <> 0 THEN x = ideautoindentsize
IF FIX(LEN(MID$(a$, 1, idecx - 1)) / x) = LEN(MID$(a$, 1, idecx - 1)) / x THEN
IF idecx - x < 1 then x = idecx - 1
a$ = LEFT$(a$, idecx - (x + 1)) + RIGHT$(a$, LEN(a$) - idecx + 1)
idesetline idecy, a$
idecx = idecx - x
ELSE
GOTO onebackspace
END IF
ELSE
onebackspace:
a$ = LEFT$(a$, idecx - 2) + RIGHT$(a$, LEN(a$) - idecx + 1)
idesetline idecy, a$
idecx = idecx - 1
END IF
END IF
GOTO specialchar
END IF
@ -3249,7 +3283,7 @@ DO
SkipBlockIndent:
IF KSHIFT = 0 THEN
x = 4
IF ideautoindent <> 0 AND ideautoindentsize <> 0 THEN x = ideautoindentsize
IF ideautoindentsize <> 0 THEN x = ideautoindentsize
K$ = SPACE$(x - ((idecx - 1) MOD x))
ELSE
K$ = ""