Skip to content

Commit 0d5dc92

Browse files
authored
Merge pull request #59 from PremadeS/rsoc-2025-blogs
Add Blogs: Shortcut Manager + Integrating Mark API
2 parents 65abd55 + 12a6d3f commit 0d5dc92

20 files changed

+185
-2
lines changed

_data/authors.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ cutter:
1717
nirmal_manoj:
1818
name: Nirmal Manoj
1919
bio: Nirmal Manoj is a CS undergraduate student at IIIT Hyderabad, India. He was a GSoC 2020 student who worked on improving the decompiler widget.
20-
image: /assets/images/blog/authors/nirmal_manoj.png
20+
image: /assets/images/blog/authors/nirmal_manoj.png
21+
22+
emad_sohail:
23+
name: Emad Sohail
24+
bio: Emad Sohail (aka PremadeS) is a CS undergraduate student at ITU Lahore, Pakistan. He was a RSoC 2025 student who worked on improving the User Experience of Cutter.
25+
github: https://github.com/PremadeS
26+
image: /assets/images/blog/authors/emad_sohail.png
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
layout: post
3+
title: "Integrating the Rizin Mark API - RSoC Project"
4+
date: 2025-10-04
5+
tags: ["Marks", "RSoC"]
6+
categories: ["Cutter", "Marks", "RSoC"]
7+
author: emad_sohail
8+
post_image: "/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/cover.png"
9+
description: "Marks in Cutter are now visual and easier to manage with tooltips, colors, and overlapping support in the Hexdump. Read about the new feature implemented by Emad Sohail, an RSoC student"
10+
---
11+
12+
As a second project of my RSoC internship, I worked on integrating the Rizin Mark API into Cutter to visually show the presence of marks in the `Hexdump` widget.
13+
14+
![Mark Complete](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-complete.gif)
15+
16+
You can find the write-up of my first project [here](https://cutter.re/shortcut-manager-rsoc)
17+
18+
## What Are Marks
19+
20+
**Marks** in Rizin let you label a range of memory addresses with a name, comment, or even a color. They’re a way to keep track of important regions in a binary.
21+
22+
Refer to [RSoC 2025 - Adding Mark API](https://rizin.re/posts/rsoc-2025-mark-api/) for more details about **Marks**.
23+
24+
## Implementation
25+
26+
For now, **Marks** are only available in the **Hexdump** widget
27+
28+
### Adding, Editing and Removing Marks
29+
30+
To make working with marks more user-friendly, we introduced a dedicated dialog in Cutter. This dialog, implemented in `MarkDialog`, takes user input and communicates with the `Core()` instance to add or edit marks. Through it, users can visually set the start and end addresses, give the mark a name, add a comment, and even pick a color.
31+
32+
![Add mark dialog box](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-add-dialog.png)
33+
34+
Actions for adding, editing, and removing marks are integrated into the context menu.
35+
36+
![Context menu actions for marks](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-context-menu.png)
37+
38+
A default shortcut key `M` was also introduced in `DefaultShortcuts` to quickly trigger the **Add Mark** action.
39+
40+
### Visualizing Marks
41+
42+
Once adding and editing marks was in place, the next step was to give them a proper visual representation. This happens directly inside the `Hexdump` widget. Before drawing the **Data bytes** and **ASCII** characters, the widget first queries the `Core()` instance for all mark items that overlap with the current **viewport**. These are collected in a `MarkDescription` container.
43+
44+
```c
45+
struct MarkDescription
46+
{
47+
RVA from;
48+
RVA to;
49+
QString name;
50+
QString realname;
51+
QString comment;
52+
QColor color;
53+
};
54+
```
55+
56+
Each mark is then rendered in its assigned color, and finally the **Data bytes** and **ASCII** characters are drawn on top so the marks integrate smoothly into the **Hexdump** view.
57+
58+
![Two highlighted marks](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-highlight.png)
59+
60+
### Blending Overlapping Marks
61+
62+
To handle **overlapping Marks**, their colors are blended to create a combined color for the overlapping region. This is achieved by setting the alpha of each mark’s color to **50%**, allowing the `QPainter` object to automatically mix them when drawing the overlapped areas.
63+
64+
![Two highlighted overlapping marks](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-highlight-overlap.png)
65+
66+
Here, the **overlapping** region is highlighted by a subtle green color.
67+
68+
### Tooltip
69+
70+
To help distinguish between different marks, we use `QToolTip`. When the user hovers over a marked address, a **tooltip** appears showing a small colored circle along with the mark’s name.
71+
72+
![Single mark tooltip](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-tooltip.png)
73+
74+
If **multiple** marks overlap at the same address, the tooltip lists them all line by line, with priority given to the most recently added mark.
75+
76+
![Overlapping marks tooltip](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-tooltip-overlap.png)
77+
78+
The **tooltip** is designed to follow the cursor. This was achieved with a small trick: first set the `QToolTip` text to the intended text plus a trailing space, and then immediately update it with the actual text. This forces Qt to redraw the tooltip at the new cursor position while keeping the content unchanged.
79+
80+
![Mark tooltip animation](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-tooltip-animation.gif)
81+
82+
### Removing and Editing Overlapping Marks
83+
84+
Since our feature now supports overlapping marks, we needed a way to remove or edit a mark that is completely contained inside another mark. Previously, the only way to access such a mark was by first removing the marks on top of it and then re-adding them, which was inconvenient.
85+
86+
To solve this, the **Remove** and **Edit** actions in the context menu now list all of the marks present at the selected address along with their names. This allows the user to directly choose which mark to edit or remove without disturbing the others.
87+
88+
![Remove mark submenu](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-remove-overlap.png)
89+
90+
## Challenges
91+
92+
Everything worked fine until we hit an issue: whenever the cursor moved inside a highlighted mark range, the background reverted to Cutter’s default color instead of staying with the mark’s highlight. This happened because the cursor redraw overwrote the background each time it moved.
93+
94+
If there was only one mark at the cursor address, fixing this would be easy: just query the mark and repaint the background with its color. But since multiple marks can overlap at the same address, we needed a smarter approach. To solve this, we introduced a helper function `getBlendedMarksColorAt()` inside `CutterCore`, which calculates the final blended color for all marks at a given address.
95+
96+
## Future Improvements
97+
98+
A cool idea for future work could be to create another tab alongside the **Parsing** and **Information** tabs in the right panel, dedicated to **Marks**.
99+
This tab would display all added marks in a table-like view with their names and allow quick interaction.
100+
101+
Clicking on a mark would open its details (such as comment, color, etc.) and provide options to directly edit or remove it without needing to use the right-click context menu.
102+
Additionally, double-clicking on a row could automatically move the **cursor** and **viewpoint** to the starting address of the selected mark, making navigation much faster and more intuitive.
103+
104+
![Right pane highlighted with arrow and red box](/assets/images/blog/posts/inetgrating-the-rizin-mark-api-rsoc/mark-future-improvement.png)
105+
106+
And also extend **Marks** support to different widgets (Disassembly, Graph, etc.).
107+
108+
## Conclusion
109+
110+
The integration of the Rizin Mark API in Cutter enables adding, editing, and managing overlapping marks directly in the Hexdump. With tooltips and context menu actions, it streamlines annotating binaries while leaving room for future enhancements.
111+
112+
This was no doubt a great learning experience, and at the end I would like to thank [@xvilka](https://github.com/notxvilka) for this amazing opportunity and also [@karliss](https://github.com/karliss) and [@deroad](https://github.com/wargio) for the help and guidance.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: post
3+
title: "Shortcut Manager - RSoC Project"
4+
date: 2025-10-04
5+
tags: ["Shortcuts", "RSoC"]
6+
categories: ["Cutter", "Shortcuts", "RSoC"]
7+
author: emad_sohail
8+
post_image: "/assets/images/blog/posts/shortcut-manager-rsoc/cover.png"
9+
description: "Introducing a centralized Shortcut Manager in Cutter for improved consistency and maintainability. Read about the improvements made possible by Emad Sohail, an RSoC student"
10+
---
11+
12+
# Shortcut Manager - RSoC Project
13+
14+
Greetings! I'm Emad Sohail (aka PremadeS), a 2nd-year CS undergraduate student at Information Technology University - Lahore. You can find me on [Github](https://github.com/PremadeS) and [LinkedIn](https://www.linkedin.com/in/emad-sohail-130b3b265/).
15+
16+
This summer I worked on improving the user experience of Cutter.
17+
18+
This was the first project. The main objective of this project was to introduce a universal **Shortcut Manager** in Cutter and provide a flexible setup that can support custom shortcuts in the future with minimal additions.
19+
20+
You can find the write-up of my second project [here](https://cutter.re/integrating-the-rizin-mark-api-rsoc).
21+
22+
## Why a Shortcut Manager
23+
24+
Default key sequences, *also referred to here as shortcuts*, were previously defined in their respective classes. While this approach works if the codebase is small, it becomes exceptionally difficult to manage as the project grows, making it hard to keep track of which shortcuts are assigned to which functions. On top of that, because the key sequences were scattered across different files, there was no way to create a centralized view that allows the user to see the default shortcuts and their respective actions.
25+
26+
## Design Goals
27+
28+
The **Shortcut Manager** was designed with three key goals:
29+
30+
1) **Consistency:** Shortcuts should behave uniformly across the application, regardless of whether they originate from a `QAction` or a `QShortcut`.
31+
2) **Maintainability:** All default shortcuts must be in the same place, allowing developers to quickly add, remove, or edit key sequences without needing to look through multiple files.
32+
3) **Extensibility:** The system should provide a solid foundation that can be expanded in the future, enabling features like custom user-defined shortcuts.
33+
34+
## Implementation
35+
36+
Default key sequences are stored in a `Shortcut` struct, each mapped to a unique ID within `shortcuts/DefaultShortcuts` using a **hashmap**. The `Shortcut` struct holds both the key sequence and a descriptive text string, along with a context string that is particularly useful for translations.
37+
38+
Whenever a `QAction` or `QShortcut` inside any class wants to register a key sequence, it queries the `ShortcutManager` class through a singleton object defined by `Shortcuts()`, using the unique ID.
39+
40+
The `ShortcutManager` then looks up the corresponding entry in the default shortcuts map. If a matching ID exists, it returns the associated key sequence; if not, it logs a warning and returns an empty `QKeySequence` object.
41+
42+
![Shortcut manager process flowchart](/assets/images/blog/posts/shortcut-manager-rsoc/shortcut-registering-flowchart.png)
43+
44+
To make the process even simpler, the `ShortcutManager` also provides utility methods that return fully configured `QAction` or `QShortcut` objects based on the given ID. This not only streamlines shortcut creation but also hides the underlying complexity, keeping the codebase clean and consistent.
45+
46+
A Default Shortcuts widget has also been introduced, allowing users to easily view all default key sequences alongside their corresponding actions. It also includes a search bar, making it simple to quickly find specific shortcuts or actions. [PR #3504](https://github.com/rizinorg/cutter/pull/3504/)
47+
48+
![Cutter Shortcut Filter](/assets/images/blog/posts/shortcut-manager-rsoc/shortcut-widget-filter.gif)
49+
50+
## Future Improvements
51+
52+
While the **Shortcut Manager** already improves consistency and maintainability, it also lays the groundwork for more advanced functionality:
53+
54+
**Custom Shortcuts:** In the future, users will be able to define and register their own shortcuts through Cutter’s interface.
55+
56+
**Profiles and Configurations:** A logical next step would be to allow different sets of shortcuts for different profiles or workflows, making it easier to switch between tailored setups.
57+
58+
## Conclusion
59+
60+
The introduction of the **Shortcut Manager** marks an important step in making Cutter more user-friendly and maintainable. By centralizing shortcuts, we’ve eliminated fragmentation in the codebase while also opening the door to future enhancements. While the project itself was relatively small in terms of code changes and complexity, its impact and long-term benefits are substantial.
748 KB
Loading
455 KB
Loading
20.1 KB
Loading
1020 KB
Loading
434 KB
Loading
327 KB
Loading
430 KB
Loading

0 commit comments

Comments
 (0)