c94aa72015
create 'MakeIfCharFolderNext' functor, which mirrors the 'MakeIfCharFolderPrev' functor that we already have
Humza Shahid2025-09-17 02:20:36 +01:00
97936b83a0
in TextBuilder functions, when we encounter a newline, we want any cursor here to be drawn after a linebreak (after the posX and posY values go to the next line) and not before
Humza Shahid2025-09-16 22:29:19 +01:00
1adb74df2c
pull in new brolib-sml changes (which just changes one particular function's name to be clearer), and modify code to use the correct name
Humza Shahid2025-09-16 22:20:55 +01:00
c4fedc6434
fix 'Cursor.getLineStartIdx' function, which should look at the left nodes if there is no relevant line in this node
Humza Shahid2025-09-16 22:09:15 +01:00
749a0d0e5f
better naming for a function in line_gap.sml, making it clear that it takes an index and returns the line number that this index is at.
Humza Shahid2025-09-16 21:48:05 +01:00
96521f358f
when looping through a DFA in a functor, make sure we return the absolute index to the calling function and not a modified version of the absolute index which has already been clipped
Humza Shahid2025-09-16 21:35:48 +01:00
12478f8ac2
remove references to 'Cursor.clipIdx' and delete that function once it is no longer used
Humza Shahid2025-09-16 16:08:01 +01:00
578d3af5ec
remove changes to temp.txt which were only for testing
Humza Shahid2025-09-16 15:55:16 +01:00
19d2235686
refactor 'MakeNormalDelete.removeLineBreaks' function to remove function call to 'Cursor.clipIdx', instead relying on textLength field in buffer
Humza Shahid2025-09-16 15:53:41 +01:00
2c5449dc0a
rewrite 'MakeMove' functor in fcore/move.sml to use textLength field instead of Cursor.clipIdx function
Humza Shahid2025-09-16 07:59:26 +01:00
148b108062
when using 'G' command to move to end fo file, use the 'textLength' field to calculate the new bufferIdx, which is more sensible than using the LineGap's idx for the same purpose
Humza Shahid2025-09-16 07:52:47 +01:00
3d9bf962e7
handle additional deleteLine edge case
Humza Shahid2025-09-16 07:40:58 +01:00
70ffea21b3
fix the last MakeNormalDelete.deleteLine bug: if we delete such that the startIdx (prior to deletion) becomes longer than the text in the buffer, we move the cursor to the start of the last line
Humza Shahid2025-09-16 07:01:55 +01:00
6507b9d49c
adjust MakeNormalDelete.deleteLine implementation slightly, because the previous implementation did not delete the last character when we are at the end of the file
Humza Shahid2025-09-16 06:29:35 +01:00
bef4620cdb
amend LineGap.append function: previously, we were calculating the updated textLength and lineLength, but we were not using them, instead passing the old parameters instead. Now we use them as well.
Humza Shahid2025-09-16 05:36:26 +01:00
169f96f459
fix exception when the buffer is empty
Humza Shahid2025-09-16 04:35:49 +01:00
0793744e24
minor bug fix: when we start looping backwards in a DFA and the rightStrings is empty, start iterating from leftStrings if possible
Humza Shahid2025-09-16 03:05:33 +01:00
820a6c2462
copy new file order from shf.mlb to shf-tests.mlb, and remove split-string tests because we have tried to refactor string-search logic to be separate from the data structure
Humza Shahid2025-09-16 01:25:27 +01:00
873fa1b1ac
pull in update to brolib-sml, which gives us a LineGap that has textLength and lineLength fields
Humza Shahid2025-09-14 15:54:59 +01:00
09fe611efb
fix tracking of textLength and lineLength fields, which were previously buggy in only one delete branch; the current commit fixes that branch and verifies the tests pass
Humza Shahid2025-09-14 15:48:26 +01:00
a95e90214d
improve test reporting information a bit
Humza Shahid2025-09-14 15:30:47 +01:00
1c59dbf943
implemented textLength and lineLength tracking in line_gap.sml: need to check if they are valid next
Humza Shahid2025-09-14 15:23:53 +01:00
76dd6b2b2a
begin tracking and adjusting textLength/lineLength for delete functions
Humza Shahid2025-09-14 13:12:49 +01:00
eebf793fbf
refactor test code to check if textLength and lineLength are also correct
Humza Shahid2025-09-14 12:54:23 +01:00
92a98bfb56
update all functions in line_gap.sml to track textLength and lineLength, except for test code and delete functions
Humza Shahid2025-09-14 12:41:50 +01:00
52f0da2751
refactor LineGap.append function to track textLength and lineLength
Humza Shahid2025-09-14 12:27:11 +01:00
9927e6bf1c
begin adding textLength and lineLength values in line_gap.sml (they are currently kept up to date only in the insert functions)
Humza Shahid2025-09-14 12:22:15 +01:00
ae1772605b
in TextBuilderWithHighlight.build, check when we encounter a \n if we would be past the last line, and return the acc if so, or else continue looping
Humza Shahid2025-09-14 10:39:51 +01:00
9b34014af1
a few bug fixes to NORMAL_SEARCH_MODE: the main one is that we were passing the general searchString to the resize function before, and we were drawing the wrong string because of that; another bug fix is that, on resizing, we have to update the mode to contain the recalculated searchScrollColumn
Humza Shahid2025-09-14 10:28:42 +01:00
f1a06f946d
add searchScrollColumn to NORMAL_SEARCH_MODE variant, and update and recalculate it where needed
Humza Shahid2025-09-14 09:50:07 +01:00
b556fc7d63
extract a reusable function to calculate the scroll column in different contexts (can be used for a plain string or a LineGap.t; doesn't matter)
Humza Shahid2025-09-14 09:22:37 +01:00
428208f9bf
when text is wide enough to be centered, also centre the search bar
Humza Shahid2025-09-14 09:14:22 +01:00
4bc6c54951
in TextBuilder.build functions, when we encounter a space, check if we are before the scroll column's start, and set the x position to startX if so. This is done in preparation for the character which is actually at the scroll column's start, which will be added at the wrong offset unless we do this.
Humza Shahid2025-09-14 08:42:46 +01:00
120568a18d
modify 'TextBuilder.initEnv' function to take 'startX' and 'startY' parameters, instead of hardcoding the startX/Y inside the function, and change width/height calculations to take these parameters into account
Humza Shahid2025-09-14 08:24:37 +01:00
2ab48626cd
remove 'skipToFirstVisibleColumn' function in TextBuilder, as control flow is simpler if we have fewer mutually recursive functions and we can implement its functionality in the 'build' function instead. Also change the 'z' values for cursor and highlight; the cursor should appear above the highlight and now it does, but it previously didn't
Humza Shahid2025-09-13 23:22:40 +01:00
7a388f2983
add TextScroll function for centering line to cursor, and use it in 'NormalFinish.centreToCursor' function
Humza Shahid2025-09-13 18:23:55 +01:00
18d2579605
remove todo-exception from 'G' (NormalMove.goToEnd) command. The todo was a reminder to implement a way to get the scroll line when moving to the end. We have that implemented now.
Humza Shahid2025-09-13 18:15:30 +01:00
bfb653e059
pull in new changes to brolib-sml, which fixes the LineGap.goToLine function to properly go to the start of the line
Humza Shahid2025-09-13 18:04:23 +01:00
26862436d0
fix LineGap.goToLine bug: we weren't properly searching to check if the start of the searchLine was accessible in the node we stopped at
Humza Shahid2025-09-13 17:58:42 +01:00
bbe39f90d4
move cursor to low/cursorIdx in helper function
Humza Shahid2025-09-13 08:48:00 +01:00
9208c47622
fix exception caused by resizing in normal mode: we were passing 'buffer' to the TextScroll function previously, but we were meant to be passing 'newBuffer'. We are passing 'newBuffer' in this new commit as we are meant to.
Humza Shahid2025-09-13 05:31:11 +01:00
2a332f543a
minor adjustment to vertical TextScroll: we shouldn't need to move the cursor to the very line in the visible area, or the ver first line in the visible area, to scroll. We scroll if the cursorLine is some distance close to either edge instead.
Humza Shahid2025-09-13 05:24:51 +01:00
668dd07699
pull in new version of brolib-sml so that we can get bug fixes for LineGap.getLineNumberOfIdx, delete the TextWindow structure (which was previously used to get the start line to draw from), and replace previous usages of TextWindow with TextScroll.getStartLine. This enables us to scroll in a way tailored to the reimplemented TextBuilder (which do not wrap lines or characters)
Humza Shahid2025-09-13 05:12:17 +01:00
737e8695e7
fix bugs in helper functions for 'LineGap.getLineNumberOfIdx'. Main bug was that we were passing 'curLine' to 'getLineNumberRight' twice, instead of first passing 'curIdx' and then 'curLine' afterwards.
Humza Shahid2025-09-13 04:55:27 +01:00
5c7ec252c2
don't index into line vector when getting line number from index; instead, just get how many previous-lines there are in the vector (if any) and add it to the line number of the current node. We do this because we are trying to get the line number of a particular index; accessing the line vector's contents (which are string indices) is not necessary nor helpful for that, but getting the relative line number is helpful for that
Humza Shahid2025-09-13 03:51:33 +01:00
db6fd56aca
perform bounds checking when we try to index into a vector, in LineGap's 'getLineNumberOfIdx' helper functions
Humza Shahid2025-09-13 03:32:35 +01:00
a3b00e09d8
port over bug fixes from mutually recursive functions from test-builder-with-cursor.sml to text-builder-with-highlight.sml
Humza Shahid2025-09-13 03:02:13 +01:00
916e94eaaa
fix bug: when we want to skip to next line in TextBuilderWithCursor, we were using binary search on the search list. The search list contained the indices of matched searches, but what we wanted to use binary search on are the lines, as the lines can help us find the next linebreak if any. So, we perform binary search on the lines vector this time to fix the bug.
Humza Shahid2025-09-13 02:48:07 +01:00
20a542df29
in BinSearch.equalOrMore and BinSearch.equalOrLess, return ~1 if no item is found, for the sake of less ambiguity in usage. Functions that call these have also been adapted.
Humza Shahid2025-09-13 02:18:14 +01:00
53a4265b07
add back a way to trigger exceptions manually to cause a logging error
Humza Shahid2025-09-13 01:47:57 +01:00
a99b6c8df8
implement smoother horizontal scrolling. If the new column is already visible without changing the previous scroll column, then don't change. If the new scroll column is prior to the old, then scroll backwards; else, scroll forwards.
Humza Shahid2025-09-13 01:43:31 +01:00
9e76a38ece
fix bug in 'TextBuilderUtils.initEnv'. When we have a wide enough space that we can centre the text, we set the 'scrollColumnEnd' field to the length of how many columns we can display. However, we want 'scrollColumnEnd' to contain the last column that can be drawn, not the length of how many columns we can draw. So now we have fixed tis.
Humza Shahid2025-09-13 01:16:29 +01:00
f2ec6b80c2
fix bug when the cursor is on the last column of a horizontally-scrollable line. Before this commit, the last column/character was not visible. Now it is. We fixed this by decrementing the 'howManyColumnsCanWeFit' value in the 'TesxtScroll.getScrollColumn' function by 1. This works because it was an off-by-one error that caused this bug in the first place (we didn't previously count column 0 as visible and taking up space)
Humza Shahid2025-09-13 01:03:44 +01:00
295bdc35cf
fix bug where some lines were not scrolling horizontally properly. The issue was that, when encountering a line break in 'skipToFirstVisualColumn' function, we should have recursively called the 'skipToFirstVisualColumn' function instead of the 'build' function. The reason is that our current column after a line break is 0, but we don't know if the start column to display is necessarily 0 in all cases.
Humza Shahid2025-09-13 00:14:07 +01:00
b9e2da3ff9
add function to skip to first visible column in TextBuilderWithCursor (sometimes the function is buggy, which I need to fix)
Humza Shahid2025-09-13 00:02:44 +01:00
422d6ad9ac
fix bugs in implementing and using text buffer. Some functions did not save the drawMsg to the app's state, which we means we didn't draw in those cases. The text builder functions also drew cursors on characters even when the cursor is not at this position. Both of these bugs are fixed.
Humza Shahid2025-09-12 23:21:53 +01:00
77a64ae794
previously forgot to draw char in text builder, but we do that now
Humza Shahid2025-09-12 14:02:38 +01:00
b6de188f7d
create a separate directory for different text builders
Humza Shahid2025-09-12 08:57:17 +01:00
9ec74380c4
fix compiler errors related to new buildTextString implementation
Humza Shahid2025-09-12 08:13:18 +01:00
a2c3df65f7
add mutually recursive functions to skip to start of next line in text builder
Humza Shahid2025-09-12 08:05:19 +01:00
4fb35d075f
done implementing one text builder function
Humza Shahid2025-09-12 05:35:49 +01:00
251e7e6962
begin reimplementing TextBuilder functions to use line-wrapping instead of char-wrap
Humza Shahid2025-09-12 05:25:57 +01:00
8698333f5b
refactor to make sure that we count the visual scroll column on move/delete, in normal mode
Humza Shahid2025-09-11 23:43:09 +01:00
ab177dbd7e
pull in new version of brolib-sml, which adds a function to retrieve the line number of an index
Humza Shahid2025-09-11 18:02:25 +01:00
5d2a2ef737
add function to get line number of LineGap to signature, so that it is available to callers
Humza Shahid2025-09-11 18:01:19 +01:00
92006ae680
add functions to get line number (where first line is 0) to line_gap.sml
Humza Shahid2025-09-11 17:59:03 +01:00
dfb7ecb867
add new function to calculate the startLine
Humza Shahid2025-09-11 17:30:49 +01:00
580f014481
fix getScrollColumn calculation: the right calculation is to subtract the column number by how many columns we can fit
Humza Shahid2025-09-11 17:09:43 +01:00
77439acef6
add function to get the appropriate scroll column
Humza Shahid2025-09-11 16:17:56 +01:00
e85ac5e806
add visualScrollColumn' field to app type, which will record the scroll position for us
Humza Shahid2025-09-11 15:26:30 +01:00
5e7f311dc7
in ffi, enable GL_DEPTH_TEST and also clear the GL_DEPTH_BUFFER_BIT on each frame; I forgot this before, but it is essential for proper depth testing/layering
Humza Shahid2025-09-11 02:43:13 +01:00
4744d9bfa8
pull in new version of cozette-sml, which had a buggy version of the glyph 0 before
Humza Shahid2025-09-11 02:15:54 +01:00
5ee4d06375
fix version of ascii-zero which has a z-index (the previous edit was manual and specified the 'z' parameter in the wrong places)
Humza Shahid2025-09-11 02:13:41 +01:00
bf18e143c7
refactor text builder to use z-index for creating text vector
Humza Shahid2025-09-11 02:02:41 +01:00
0f78a25382
add z-index parameter to cursors, and refactor code to use them
Humza Shahid2025-09-11 01:53:13 +01:00
2e0f749229
adjust imperative shell to use xyz coordinates for position, instead of simply xy; need to ensure the functional core code outputs a vector in this format too
Humza Shahid2025-09-11 01:43:23 +01:00
781691060c
begin refactoring code to use a single vertex buffer for all shapes
Humza Shahid2025-09-11 01:31:19 +01:00
62e5777f75
pull in update to cozette-vector, which will allow us to use the z-index for layering shapes below/on top of each other
Humza Shahid2025-09-10 12:30:10 +01:00
c88b8c0332
add another folder which contains fonts with z-index arguments. The z indes can be used for depth testing/letting a single vertex vector contain different layers.
Humza Shahid2025-09-10 12:26:15 +01:00
fee8ba5207
set preemptive scheduling time to change threads every 555 microseconds, instead of every 20 milliseoncds (which was the default)
Humza Shahid2025-09-10 01:52:16 +01:00
95a07bcd92
rename 'UpdateThread' structure to 'Updater', because it is no longer a separate thread
Humza Shahid2025-09-10 01:44:25 +01:00
dc3009bf54
create separate mailbox structures for draw and input messages, because our plan is to: 'handle input + drawing on a single thread'
Humza Shahid2025-09-10 01:04:56 +01:00
0a0f723b9b
add '<count>yx' function to both yank and delete a specified character
Humza Shahid2025-09-07 23:39:33 +01:00
fd303c0f7d
reimplement part of 'deleteToEndOfLine' function in make-normal-delete.sml, so that it doesn't rely on the 'helpRemoveChr' function, and so we can delete the 'helpRemoveChr' function.
Humza Shahid2025-09-07 23:24:31 +01:00
e2acdd90f4
new implementation for removing characters with 'x', which is simpler than previous implementation as well
Humza Shahid2025-09-07 22:30:39 +01:00
a037211763
add a new test validating that the cursor does not move when cursor is on an empty line
Humza Shahid2025-09-07 21:09:20 +01:00
11212430f4
fix bug with ViDlrDfa.next: we previously did not consider the case of cursor starts on a line containing nothing but a blank \n newline. We consider this now, returning the same index when it occurs.
Humza Shahid2025-09-07 20:59:13 +01:00
b7e0bab04a
modify dedent functionality to support dedenting multiple lines, acting on count parameter
Humza Shahid2025-09-07 15:12:34 +01:00