cutter/src/common
Premade 867c54e838
Optimize disassembly scroll and selection logic (#3646)
1. Scroll by visual lines instead of disassembly lines (see #3604)

Previously whenever a scroll happened, cutter cleared all of the disassembled
lines it had and queried rizin again, even if the scroll was only for one
instruction. This causes two problems:

* All of the lines have to be queried again making scrolling slow.
* Since an instruction can have multiple metadata lines attached to it, it meant
  that whenever a user scrolled a single instruction all of the metadata lines
  will also be scrolled - making scrolling feel choppy.

To solve this we keep a buffer of "max visible lines * 5" which is filled in as
user scrolls, meaning at first only "max visible lines" are queried from rizin,
if user scrolls upwards the entire "max visible lines" above the current top
instruction is fetched and prepended to our "lines" buffer. Since the previous
lines are still saved - if the user scrolls back down we can just show those
specific lines from our buffer instead of querying again.

Lines are erased from start or end based on scroll direction if the buffer
exceeds the size cap of "max visible lines * 5" The "lines" buffer is fully
cleared if user seeks to some address using some external signal - like the
Visual nav bar at the top (basically seeking using any method other than
directly clicking on the instruction line itself)

2. Adds infinite selection via mouse and keyboard

There was no way in cutter to select more lines than whats currently shown on
screen and there was also no way to select text via keyboard. This is done via
manually handling the selection instead of letting Qt handle it. The selection
is preserved no matter how far user scrolls up or down.

3. Fixes empty space at the bottom of disassembly widget viewport

Whenever "max visible lines" were calculated it didn't account for the fact that
the last line might be partially visible meaning there is not enough space to
display it fully, which created empty space at the bottom

4. Adds a visible/blinking cursor to the disassembly panel

Avoids the issue of not knowing which line we are on, if the line contains
similar text that is highlighted. Also helps to know where selection will start
using physical keys
2026-07-17 12:52:28 +02:00
..
AddressableItemModel.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
AddressableItemModel.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
AnalysisTask.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
AnalysisTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
AsyncTask.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
AsyncTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BasicBlockHighlighter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BasicBlockHighlighter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BasicInstructionHighlighter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BasicInstructionHighlighter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BinaryTrees.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BugReporting.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
BugReporting.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CachedFontMetrics.h RichTextPainter: Draw text using QPoint instead of QRect (#3613) 2026-05-26 14:12:13 +05:00
Colors.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Colors.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
ColorThemeWorker.cpp Fix portable rizin system themes loading (#3632) 2026-06-25 11:28:12 +02:00
ColorThemeWorker.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CommandTask.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CommandTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Configuration.cpp Add a toggle for showing raw strings in Strings Widget (#3617) 2026-06-19 17:56:16 +05:00
Configuration.h Add a toggle for showing raw strings in Strings Widget (#3617) 2026-06-19 17:56:16 +05:00
CutterLayout.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CutterLayout.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CutterSearchable.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CutterSearchable.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CutterSeekable.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
CutterSeekable.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Decompiler.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Decompiler.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DecompilerHighlighter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DecompilerHighlighter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DirectionalComboBox.cpp Apply clang-format 2021-01-24 18:34:16 +02:00
DirectionalComboBox.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DisassemblyHelper.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DisassemblyHelper.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
DisassemblyPreview.cpp Fix namespace alias DH conflict with OpenSSL typedef (#3620) 2026-06-23 09:25:44 +05:00
DisassemblyPreview.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
FunctionsTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Helpers.cpp Optimize disassembly scroll and selection logic (#3646) 2026-07-17 12:52:28 +02:00
Helpers.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
HighDpiPixmap.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
HighDpiPixmap.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
InitialOptions.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
IOModesController.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
IOModesController.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Json.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Json.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
LinkedListPool.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
MdHighlighter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
MdHighlighter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
Metrics.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
PythonAPI.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
PythonAPI.h Don't compile files for features that are disabled. (#2561) 2021-01-11 23:49:54 +02:00
PythonManager.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
PythonManager.h Apply clang-format 2021-01-24 18:34:16 +02:00
QtResImporter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
QtResImporter.h Don't compile files for features that are disabled. (#2561) 2021-01-11 23:49:54 +02:00
RefreshDeferrer.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RefreshDeferrer.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
ResourcePaths.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
ResourcePaths.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RichTextPainter.cpp RichTextPainter: Draw text using QPoint instead of QRect (#3613) 2026-05-26 14:12:13 +05:00
RichTextPainter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RizinTask.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RizinTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RunScriptTask.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
RunScriptTask.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SelectionHighlight.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SelectionHighlight.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SettingsUpgrade.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SettingsUpgrade.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
StringsTask.h Add a toggle for showing raw strings in Strings Widget (#3617) 2026-06-19 17:56:16 +05:00
SvgIconEngine.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SvgIconEngine.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SyntaxHighlighter.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
SyntaxHighlighter.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
TempConfig.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
TempConfig.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
UpdateWorker.cpp Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00
UpdateWorker.h Refactor code to match new style (#3612) 2026-05-21 14:26:49 +05:00