I created a new App struct to store the app's current state in. This makes the code a little bit cleaner, as it separates the app's state from the drawing logic.
With this change, the search feature has been optimized: now it caches the results in the app struct, and it performs new searches if and only if it needs to (For now, it searches only once, but this will become more relevant once we add a search bar).
Also, by doing this i fixed the fact that on empty searches nothing was shown (now it shows every possible template), and the broken wrap around when a user tries to go up at index zero in the list, or down at the last index (previously, the cursor would disappear, and the program would crash if you pressed Enter).
All these changes will help to create further menus more easily, as now you can potentially track what menu you're in directly inside the app status.
I created a new App struct to store the app's current state in. This makes the code a little bit cleaner, as it separates the app's state from the drawing logic. With this change, the search feature has been optimized: now it caches the results in the app struct, and it performs new searches if and only if it needs to (For now, it searches only once, but this will become more relevant once we add a search bar). Also, by doing this i fixed the fact that on empty searches nothing was shown (now it shows every possible template), and the broken wrap around when a user tries to go up at index zero in the list, or down at the last index (previously, the cursor would disappear, and the program would crash if you pressed Enter).
All these changes will help to create further menus more easily, as now you can potentially track what menu you're in directly inside the app status.