@@ -4,7 +4,6 @@ if (!isOpen) {
44 }
55} else {
66 var prevConsoleString = consoleString;
7- maxScrollPosition = max (0 , outputHeight - visibleHeight);
87
98 if (keyboard_check_pressed (vk_escape)) {
109 if (isAutocompleteOpen) {
@@ -15,20 +14,20 @@ if (!isOpen) {
1514 } else if (self.keyboardCheckDelay (vk_backspace)) {
1615 consoleString = string_delete (consoleString, cursorPos - 1 , 1 );
1716 cursorPos = max (1 , cursorPos - 1 );
18- scrollPosition = maxScrollPosition;
17+ targetScrollPosition = maxScrollPosition;
1918 } else if (self.keyboardCheckDelay (vk_delete)) {
2019 consoleString = string_delete (consoleString, cursorPos, 1 );
21- scrollPosition = maxScrollPosition;
20+ targetScrollPosition = maxScrollPosition;
2221 } else if (keyboard_string != " " ) {
2322 var t = keyboard_string;
2423 if (!insertMode) { consoleString = string_delete (consoleString, cursorPos, string_length (t)); }
2524 consoleString = string_insert (t, consoleString, cursorPos);
2625 cursorPos += string_length (t);
2726 keyboard_string = " " ;
28- scrollPosition = maxScrollPosition;
27+ targetScrollPosition = maxScrollPosition;
2928 } else if (self.keyboardCheckDelay (vk_left)) {
3029 cursorPos = max (1 , cursorPos - 1 );
31- scrollPosition = maxScrollPosition;
30+ targetScrollPosition = maxScrollPosition;
3231 } else if (self.keyboardCheckDelay (vk_right)) {
3332 if (cursorPos == string_length (consoleString) + 1 &&
3433 array_length (filteredSuggestions) != 0 ) {
@@ -37,7 +36,7 @@ if (!isOpen) {
3736 } else {
3837 cursorPos = min (string_length (consoleString) + 1 , cursorPos + 1 );
3938 }
40- scrollPosition = maxScrollPosition;
39+ targetScrollPosition = maxScrollPosition;
4140 } else if (self.keyComboPressed (historyUpModifiers, historyUpKey)) {
4241 if (historyPos == array_length (history)) {
4342 savedConsoleString = consoleString;
@@ -47,7 +46,7 @@ if (!isOpen) {
4746 consoleString = array_get (history, historyPos);
4847 cursorPos = string_length (consoleString) + 1 ;
4948 }
50- scrollPosition = maxScrollPosition;
49+ targetScrollPosition = maxScrollPosition;
5150 } else if (self.keyComboPressed (historyDownModifiers, historyDownKey)) {
5251 if (historyPos < array_length (history)) {
5352 historyPos = min (array_length (history), historyPos + 1 );
@@ -58,7 +57,7 @@ if (!isOpen) {
5857 }
5958 cursorPos = string_length (consoleString) + 1 ;
6059 }
61- scrollPosition = maxScrollPosition;
60+ targetScrollPosition = maxScrollPosition;
6261 } else if (keyboard_check_pressed (vk_enter)) {
6362 if (isAutocompleteOpen) {
6463 self.confirmCurrentSuggestion ();
@@ -146,23 +145,30 @@ if (!isOpen) {
146145 }
147146 } else if (point_in_rectangle (device_mouse_x_to_gui (0 ), device_mouse_y_to_gui (0 ), shellOriginX, shellOriginY, shellOriginX + width, shellOriginY + height)) {
148147 if (mouse_wheel_down ()) {
149- scrollPosition += scrollSpeed;
148+ targetScrollPosition = targetScrollPosition + scrollSpeed;
150149 }
151150 if (mouse_wheel_up ()) {
152- scrollPosition -= scrollSpeed;
151+ targetScrollPosition = targetScrollPosition - scrollSpeed;
153152 }
154153 }
155154 } else {
156155 if (point_in_rectangle (device_mouse_x_to_gui (0 ), device_mouse_y_to_gui (0 ), shellOriginX, shellOriginY, shellOriginX + width, shellOriginY + height)) {
157156 if (mouse_wheel_down ()) {
158- scrollPosition += scrollSpeed;
157+ targetScrollPosition = targetScrollPosition + scrollSpeed;
159158 }
160159 if (mouse_wheel_up ()) {
161- scrollPosition -= scrollSpeed;
160+ targetScrollPosition = targetScrollPosition - scrollSpeed;
162161 }
163162 }
164163 }
165- scrollPosition = clamp (scrollPosition, 0 , maxScrollPosition);
164+
165+ // Updating scrolling
166+ var lerpValue = (scrollSmoothness == 0 ) ? 1 : remap (scrollSmoothness, 1 , 0 , 0.08 , 0.4 );
167+ scrollPosition = lerp (scrollPosition, targetScrollPosition, lerpValue);
168+ scrollPosition = clamp (scrollPosition, 0 , maxScrollPosition)
169+ if (scrollPosition == 0 || scrollPosition == maxScrollPosition) {
170+ targetScrollPosition = clamp (targetScrollPosition, 0 , maxScrollPosition);
171+ }
166172
167173 if (consoleString != prevConsoleString) {
168174 // If the text at the prompt has changed, update the list of possible
0 commit comments