Table of contents
No headings in the article.
It's been a while since I found time and energy to work on my side project, MyStudio IDE, written in Rust using GTK.
After a few weeks of hiatus, I started hacking on some things on and off and I finally have something worth sharing with you all.
There's been quite a few changes in the project compared to previous release v0.1.2
Notable ones include:
main_window.uiand create multiple instances on-the-fly using code.
There are now ready-to-use functions in-place to manage this.
notebook.rsto a Rust module and split it's functionality into several Rust files.
This change brings me great joy as the code is more maintainable to my eyes.
All new PRs must be raised against
master. I felt using
developmentbranch would become a burden.
Update application layout so
GtkNotebooktabs aren't hidden when scrolling vertically.
This update broke the File Save feature in the project. I will talk more about this in few moments.
GtkNotebooktab caching APIs as part of
NotebookTabCachestruct instead of individual functions inside
This change is a conflict for me as it manipulates a static
Vec<NotebookTabCache>which is technically not part of the cache struct.
Feature broken - Save Changes:
This feature works by fetching contents of
SourceView, converting them to Rust string slice and writing it to disk.
pageare interchangeable in this context.
GtkNotebookcalls them pages; I refer to them as tabs, even in code, for my understanding.
We first need to gain access to
TextBuffer of the
SourceView widget using
GtkNotebook by finding tab (or page) index.
The application has an internal cache to keep track of open tabs for quick use. It is also used to switch to existing tab when clicking on file in Workspace Explorer, if it is already open.
Here's how this cache looks like:
pubis an access specifier in Rust which is equivalent to
publicin other languages.
structis how we hold groups of values. Learn more
Previously on MyStudio IDE:
file_path from cache and compare it to currently open file (ref) to fetch
page number (or tab index) from
GtkNotebook. This would give us
SourceView widget of currently open file which can be used to gain access to it's
The layout looked as follows:
However, my fix for vertical scrolling issue has changed the layout slightly. I fixed it by placing a
GtkScrolledWindow (which is the widget used to add scrolling to a widget) as a "main child" widget to
This widget would have a single child,
GtkViewport (think of it as a container of other widgets).
Finally, I add my dynamically initalized
SourceView widget as a child to
The new layout looks as follows:
This layout has to be replicated, in code, for every file opened inside the editor.
The problem was, once we figure out the page number, we get a
ScrolledWindow widget however what we're looking for is its "grandchild" -
There was a
SourceView in the code which I didn't update when the layout fix was made and this ultimately broke the Save feature.
The solution was to access the first child of
ScrolledWindow and the first child of
Viewport to retrieve
SourceView widget and return it for further processing.
You can find the Git commit for this here.
Here's my layout fix commit that caused this in the first place. link
It was an easy fix however I didn't realize it until I accidentally came across it while working on the project.
The Save feature bug made me realize I need to improve how I develop this project. Here's an list of changes I'd like to bring to the project.
libmystudioRust library inside the monorepo to hold all "non-UI functionality". [DONE]
mystudio-iderepo to use
libmystudioand remove all non-essential code. [DONE]
Write unit tests for both the projects.
I'm not sure when/how/if I can find the time for these changes but I know these big steps will ensure what I've written will work as expected in the future.
Thanks for reading! Leave a comment on your thoughts and ideas for this.
You can @ me on Twitter
Update: updated Future plans progress