handle \r\n pair in 'viL' function
This commit is contained in:
@@ -12,13 +12,34 @@ struct
|
|||||||
val strIdx = cursorIdx - bufferIdx
|
val strIdx = cursorIdx - bufferIdx
|
||||||
in
|
in
|
||||||
if strIdx < String.size hd - 2 then
|
if strIdx < String.size hd - 2 then
|
||||||
(* increment if there is a character after where cursor is *)
|
(* increment if there is a character after where cursor is
|
||||||
cursorIdx + 1
|
* but first, check if we are in a \r\n pair;
|
||||||
|
* if we are, then increment cursor by 2 *)
|
||||||
|
if
|
||||||
|
String.size hd > strIdx + 2
|
||||||
|
andalso String.sub (hd, strIdx + 1) = #"\r"
|
||||||
|
andalso String.sub (hd, strIdx + 2) = #"\n"
|
||||||
|
then
|
||||||
|
(* increment cursor by 2 if we are inside \r\n pair *)
|
||||||
|
cursorIdx + 2
|
||||||
|
else
|
||||||
|
(* inccrement cursor by 1 if we are not inside \r\n pair *)
|
||||||
|
cursorIdx + 1
|
||||||
else
|
else
|
||||||
(case tl of
|
(case tl of
|
||||||
_ :: _ =>
|
_ :: _ =>
|
||||||
(* if there is another string after current head, we can increment cursorIdx *)
|
(* if there is another string after current head, we can increment cursorIdx
|
||||||
cursorIdx + 1
|
* however, first we need to check if next string is \r\n pair. *)
|
||||||
|
if
|
||||||
|
String.size hd > strIdx + 2
|
||||||
|
andalso String.sub (hd, strIdx + 1) = #"\r"
|
||||||
|
andalso String.sub (hd, strIdx + 2) = #"\n"
|
||||||
|
then
|
||||||
|
(* increment cursor by 2 if we are inside \r\n pair *)
|
||||||
|
cursorIdx + 2
|
||||||
|
else
|
||||||
|
(* inccrement cursor by 1 if we are not inside \r\n pair *)
|
||||||
|
cursorIdx + 1
|
||||||
| _ =>
|
| _ =>
|
||||||
(* if there is no string after current head, return original cursorIdx *)
|
(* if there is no string after current head, return original cursorIdx *)
|
||||||
cursorIdx)
|
cursorIdx)
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ struct
|
|||||||
buildTextStringBeforeCursor
|
buildTextStringBeforeCursor
|
||||||
( pos + 2, str, acc, startX, posY + ySpace, startX
|
( pos + 2, str, acc, startX, posY + ySpace, startX
|
||||||
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
|
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
|
||||||
, r, g, b, tl, absIdx + 1, cursorPos, hr, hg, hb
|
, r, g, b, tl, absIdx + 2, cursorPos, hr, hg, hb
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
buildTextStringBeforeCursor
|
buildTextStringBeforeCursor
|
||||||
@@ -332,7 +332,7 @@ struct
|
|||||||
buildTextStringWithinCursor
|
buildTextStringWithinCursor
|
||||||
( pos + 2, str, acc, startX, posY + ySpace, startX
|
( pos + 2, str, acc, startX, posY + ySpace, startX
|
||||||
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
|
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
|
||||||
, r, g, b, tl, absIdx + 1, cursorPos, cursorAcc, hr, hg, hb
|
, r, g, b, tl, absIdx + 2, cursorPos, cursorAcc, hr, hg, hb
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
buildTextStringWithinCursor
|
buildTextStringWithinCursor
|
||||||
|
|||||||
Reference in New Issue
Block a user