focus-editor / focus Goto Github PK
View Code? Open in Web Editor NEWA simple and fast text editor
License: GNU General Public License v3.0
A simple and fast text editor
License: GNU General Public License v3.0
set tab_size to something != 4
int main() {
int arg; // <-- press enter here
}
...
int main() {
int arg;
// <-- spaces are created here instead of tabs leading to misalignment if tab_size is set to something < 4
}
Whenever I click back into the focus window, a new cursor appears. Defocusing and refocusing adds more and more until you press escape.
I built from commit 50cbc6f.
Will try and have a look tonight.
Describe the bug
When loading a project with access to two folder of roughly 40 GB of size total (not only text data), the memory consumption increases with seemingly no end.
To Reproduce
Load a large project? Small projects seem to work just fine.
Expected behavior
Only allocate the necessary RAM that is needed.
Screenshots
The project is loaded at the beginning of the memory graph and the editor starts using more and more ram
It keeps filling the memory, see the "Committed" amount
Additional context
The two folders loaded in the project are of sizes 35.2 GB and 9.5 GB, so even if all the data is loaded, it should not be much larger than 50 GB I believe.
It's one thing that I love in vim, emacs, 4coder, and to some extent VSCode :
I'd be happy to try working on this but I might take a lot of time as I'm not super familiar with the codebase yet.
Let me know if you think this is a good idea and if my suggested flow fits within your vision.
A feature I really can't live without from emacs/vim is a basic way to complete text. The way it works is you type something like "get_" and then you press tab (or whatever keybinding) to cycle between different options like "get_entity", "get_string", "get_thing", etc. I think this feature fits in with focus's style since it's very basic and easy to understand and it's not annoying and in-your-way as IDE-style dropdown word completions.
Emacs also prioritizes completions from the current file that are nearest to the cursor and then searches for completions in the most recently opened files, which I find works extremely well.
This is what it looks like. After it cycles through all the completions it returns back to the original text that was typed in.
You could have settings that sets a max count of all the completions focus can find and you could also have a setting if you prefer the word completion to be case sensitive or not (or maybe make two separate commands for each one).
Describe the bug
It feels like there is a race condition when opening new empty buffers. When using Ctrl+N I will sometimes get a new empty buffer (expected), sometimes get a buffer with a random file from within my workspace directories (unexpected), and other times will get a crash (unexpected).
To Reproduce
Steps to reproduce the behavior:
.\focus.exe
Ctrl+N
Expected behavior
A new empty buffer is created every time
Screenshots
N/A
Additional context
Here is the stack trace from when it crashes:
Array bounds check failed. (The attempted index is 0, but the array has dimension 0, so no index is valid). Site is L:/Dev/Third-Party/focus/src/buffer.jai:109.
Panic.
A breakpoint was hit, but no debugger is attached.
Printing the stack trace:
handle_exception F:\tools\Jai\jai-beta-1-062\modules\Runtime_Support_Crash_Handler.jai:363
... (skipping OS-internal procedures)
debug_break L:\Dev\Third-Party\focus\modules\Runtime_Support.jai:12
my_panic L:\Dev\Third-Party\focus\modules\Runtime_Support.jai:143
__array_bounds_check_fail L:\Dev\Third-Party\focus\modules\Runtime_Support.jai:196
offset_to_coords L:\Dev\Third-Party\focus\src\buffer.jai:109
get_cursor_coords L:\Dev\Third-Party\focus\src\buffer.jai:125
draw_editor L:\Dev\Third-Party\focus\src\draw.jai:368
draw_frame L:\Dev\Third-Party\focus\src\draw.jai:21
main L:\Dev\Third-Party\focus\src\main.jai:228
The crash seems to be from the editor attempting to draw the buffer before the initialization code can add the first line to line_starts
? But what is stranger to me, is when the buffer opens but is loaded with the content of a random file in my workspace directories.
When I run the editor on Ubuntu 22.04.2 I see in a folder only focus-linux, there is no a project folder or another the editor's folders also
can not close the editor because I don't have a window title and I have by default the cross cursor.
Most likely answer is "no, just fork and modify source", but if I think of other editors like helix or neovim, it would be handy to have some kind of LSP support to help catch compilation issues (this can be an opt-in type of experience). I don't need an IDE-like experience. I find that go to symbol / find usages, split view, and easy file system traversal are about all I need to stay sane while working in a codebase, but I'm doing embedded work right now and the cross compilation toolchain takes forever - so being able to see comp errors as I'm developing would also be helpful.
When duplicating a line at the end of the file, the text gets appended to the last line, and no new line is created
Not a bug, but a feature suggestion
I would like to see tabs added
Why? it's part of my workflow, i like setting context trough tabs when i'm working on something instead of constantly switching buffers and typing file names, it's a waste of time
could you add a Linux version with the release binaries?
Describe the bug
On macOS the keymap combinations assume US QWERTY is the keyboard layout.
Example 1
To Reproduce with AZERTY layout
Steps to reproduce the behavior:
Expected behavior
The typing of the word 'testing' to be undone.
Actuall behaviour
The file is closed
Example 2
To Reproduce with Dvorak layout
Steps to reproduce the behavior:
Expected behavior
The typing of the word ".plist " to be undone.
Actuall behaviour
The 'Toggle Code Comment' command is issued, adding a "# " to the beginning of the line.
Describe the bug
A command associate other file that allows the user to locate a file that should be paired with the current file.
For example: .h files for the currently open .c file.
If no other file has been associated with the current file launch the open file dialog and mark whatever file is opened as corresponding to the current file.
Subsequent other file commands will simply switch between the two files.
A command to clear the association would make the feature complete.
A more general utility would be to provide a pattern matching association in config, reverting to the specific file association if the match can not be found.
When I try to do: ./focus /home/martijn/demo.cpp
, it spends about a minute scanning my home folder, installing directory watchers.
I don't know the philosophy regarding projects and where this editor fits in besides projects, but this seems not ideal.
As much of a pain as it is, it's kind of necessary :/
❯ ./focus /home/martijn/w/ClassroomPerf/server.cpp
Segmentation fault. The faulty address is 0x0, from 0xa09a8d.
./focus(platform_set_window_title_200000319+0x7d) [0xa09a8d]
./focus(update_window_title_a000001f0+0x4be) [0x9f428e]
./focus(editors_open_buffer_a000001bf+0x629) [0xa0e0f9]
./focus(editors_open_file_a000001bd+0x634) [0x9df7a4]
./focus(__program_main+0x15c7) [0xae3277]
./focus(__system_entry_point_800000125+0x45) [0xb14f25]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f1bba0b0083]
./focus(_start+0x2e) [0xb175de]
On Windows, the OS open file dialog that opens when saving a new file causes the editor to not update until the dialog is closed. This leads to confusing situations where it seems the editor is stuck but really it's just that the dialog is still opened behind the editor window. Particularly, resizing the editor window while the dialog is opened breaks the rendering for example.
Expected behavior
Ideally the editor should still update normally, without allowing the user to interact with it (window resizes for example should still be reacted to)
Add a directory as a workspace in global config, then ensure that the directory has a symbolic link to some file. In my case, it is a directory that has within it a rootfs folder, and the symlinks are common files within the rootfs that I store at the TLD so I don't have to click/cd around to find them every time.
The symbolic links are not visible when the open dialog opens.
I suspect this is not a linux issue but I could be wrong. I have a faster key repeat setting than normal, something you should be able to set up on linux and windows. The issue is that when the cursor goes off the end of the window the frame rate drops significantly. I suspect this has something to do with how you are handling events.
Editor looks awesome though! I don't have jai access but I was able to run the executable just fine.
Describe the bug
When closing the right panel using "close_other_editor" shortcut then moving to previous history, the active panel switch side
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Since we closed the right panel with the left panel active in step 4. , the left panel should still be the one active in step 5.
Version
0.1.10
I'm using focus 0.1.10 on windows 10.
I tried to open 2GB csv file.
test2310722_.csv
(exact size is 2 152 105 405 bytes)
focus editor crashed with error:
Array bounds check failed in file W:/focus/src/buffer.jai at line number 111: Provided index: -2147483335, maximum index: 2147483961
When I tried to open slightly smaller file
test2310720.csv
(exact size os 2 152 103 659 bytes)
Everything worked fine.
focus editor on windows 10 does not open files with the unicode symbols in the file name.
Example:
.\focus.exe .\test.txt
Everything works fine.
.\focus.exe .\test©.txt
Focus editor opens, but shows the main page instead of opening a file.
Same goes for files with greek or cyrillic symbols in the filename:
.\focus.exe .\testα.txt
Focus editor opens, but shows the main page instead of opening a file.
.\focus.exe .\test_кириллица.txt
Focus editor opens, but shows the main page instead of opening a file.
BTW, if you open focus editor manually and drag-and-drop files into it, it opens all files (symbols in the filenames doesn't matter).
Describe the bug
When I open the editor in windows (I have not tried other OSes), via command line .\focus_debug.exe
and then immediately hit Ctrl+Shift+P
and select Switch To Project
then picking any project I have in the given list, the program will hang for a few seconds, and then crash with the following assertion:
F:/tools/Jai/jai-beta-1-062/modules/Thread/thread_group.jai:251,5: Assertion failed!
Stack trace:
F:/tools/Jai/jai-beta-1-062/modules/Preload.jai:380: default_assertion_failed
F:/tools/Jai/jai-beta-1-062/modules/Basic/module.jai:83: assert
F:/tools/Jai/jai-beta-1-062/modules/Thread/thread_group.jai:251: shutdown
L:/Dev/Third-Party/focus/src/widgets/finder.jai:16: deinit_finder
L:/Dev/Third-Party/focus/src/workspace.jai:145: hard_reload_workspace
L:/Dev/Third-Party/focus/src/main.jai:236: main
A breakpoint was hit, but no debugger is attached.
To Reproduce
Please see the description
Expected behavior
The program should successfully load the project and display the green notification in the bottom right
Screenshots
N/A
Additional context
It seems from my searching that the finder is being shutdown before it's initialized? Replacing focus/src/widgets/finder.jai:16 with if finder.initted shutdown(*thread_group);
seems to fix the issue. But I'm unsure if the finder is expected to be initialized prior to this? If so the problem probably lies elsewhere.
I have the fix in a fork if a PR is needed, but I feel this is such a small change its probably not worth the fuss? Let me know :)
Can you please add the ability to map numpad keys? I just used to some shortcuts like ctrl+numpad4 and ctrl+numpad6 to switch between left and right editor 🙂
----------------
Version: 0.1.4
Describe the bug
In c.jai, csharp.jai, jai.jai, the tokenizer marks #char "}" as .l_brace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should be .r_brace!
I'm trying out the linux build. It ran out of the box, so props for that! Most stuff is working as expected.
However, fonts are rendered significally different from what I would expect. For example here are screenshots of Roboto Mono Regular size 17 of the same line from Sublime (top) and Focus (bottom). The individual glyphs are the same, but the spacing is way too narrow.
I'd like to use this on macOS. Can you add a macOS binary or bundle to the releases? Alternately I'd love to get into the jai beta, build focus myself, and help support this project.
Describe the bug
Some of the default key shortcuts are hardcoded and even though I delete every instance of them from the global config file, application still insists on using its own default keys.
To Reproduce
Steps to reproduce the behavior:
[[keymap]]
[editors]
[open file dialog]
[search dialog]
[common]
Expected behavior
Since the config file gives the user a config file where you can customize the key shortcuts, a removed shortcut should be removed!
This feels like an important issue since one can wish not to have an action bind to "Ctrl-O" for example.
I have connected the editor to open for example json files. But if a file is called 'für.json' (with umlauts) the editor starts without opening the file. Drag'n'drop the file into the editor, still works.
On Windows certain apps have useful options when clicking the app icon on the top left of the window (shown below).
Can Focus have an option there that shows "Open global config" or something similar that opens the global config in the editor? This can be extended to also have options that open project specific configs.
I know it there is a shortcut for this, but it would be a nice accessibility feature for those that make minimal use of shortcuts.
On command prompt, for example there is a clicking "Properties" option that opens a properties dialog.
Similar options are found in the Windows PowerShell and Git Bash terminals. I believe Cmder has it as well.
Currently, the Focus editor has this:
(Just to clarify, I'm not asking for a whole menu that lets you configure the same settings you wound in the conifg, just a menu option that maps to the command "Open global config".)
Font rendering on Windows sometimes look really bad depending on the size/scale/font. I tried messing with OGL FT code but couldn't achieve desirable results. What I wanted to do is force grayscale hinting, since this hRGB hinting is really strong and noticable on my 4K screen.
Also many fonts look weird in terms of glyph rendering, spacing can be off on certain sizes, on others it's okay. For example using Cascadia Mono you can see weird horizontal glitch in glyph t
in the middle of the vertical line.
I assume this comes down to Simp library and FreeType version that it is using so it won't be easy thing to solve I assume.
Describe the bug
Crash after history manipulation
To Reproduce
Expected behavior
Should open the left buffer on step 4 and not crash :)
Version
0.1.10
Describe the bug
Scrolling starts stuttering after a second when using scroll_viewport
key commands. Holding Shift
a moment after pressing the key-combo prevents the stuttering completely.
To Reproduce
Open big enough file and hold Alt-J/K or E/D
. You should notice stuttering a second into the scroll. Hold Shift
a moment after starting the scroll and it should disappear.
Expected behavior
Scrolling should be smooth.
Additional context
I think whatever input code controls scrolling is using "raw" text input from the keyboard. Like holding a key in a text box, it fires off an input event once, pauses, then fires them in rapid succession. Assuming that's the case, switching to Key-State based input would be the proper fix. Just a hunch though!
I tried it out for the first time, and it seems that I cannot control Focus if I'm on AZERTY keyboard layout. Also, after changing to QWERTY, I was following the default config file, and tried Ctrl-Shift-, to duplicate the editor, but that didn't work. Only Ctrl-, worked.
Minimize editor, do something else for some time (in my case use Unity editor), go back to Focus editor and it has very high CPU use that is unusable.
It happened twice in such circumstances but it's hard for me to reproduce it freely, so it might not be related to minimizing application but some other OS behaviour?
EDIT: looks like I can reproduce it by just using editor for some time and it might be related with C# files support.
Unable to save file created with ctrl-n by pressing ctrl-s or the save dialog when quitting focus.
Focus only outputs "name = 'filename" to console when pressing ctrl-s and no errors,
the "save" button in the quit focus dialog does nothing only "cancel" and "don't save" do anything.
I also didn't find a way to determine which folder it tries to write to.
I tried default config file and running focus as sudo.
Linux Mint 21.1 Cinnamon with 5.19.0-43-generic Kernel.
focus-linux Version 0.1.10.
Notice: I sent an email already about this to Jon, since it's a fix to be done in the Thread module, but I'm still making an issue to keep track of the bug and provide a quick fix.
The editor crashes when logging in a separate thread, when the logger is session_logger (really it crashes when a logger is set that does not expect context.logger_data to be null).
The fix for this would be to set each thread's starting_context.logger_data to context.logger_data, specifically:
In workspace.jai, line 43:
// @Temporary: fix for logger starting context logger data not being set correctly in thread_init
for * file_list_thread_group.worker_info
it.thread.starting_context.logger_data = context.logger_data;
line 75:
// @Temporary: fix for logger starting context logger data not being set correctly in thread_init
for * scanner_thread_group.worker_info
it.thread.starting_context.logger_data = context.logger_data;
Describe the bug
A clear and concise description of what the bug is.
I downloaded version 0.1.8 for Linux and upon opening the binary was showing that it was version 0.1.7. I double checked and yes I am downloading the correct file. A quick glance at source shows that version 0.1.8 is defined in first.jai or something like that, so I don't know where this stale reference is coming from. Is this a field in some config file somewhere? Most likely user error, but I thought I would report it anyway.
Describe the bug
UI elements react to the mouse position (they are visually hovered), even when the window is hidden.
This happens on Windows (haven't tested any other platform), this might be different on other OSes since it's a window thing.
To Reproduce
Just put a window in front of the editor window and hover the mouse over UI elements like a scrollbar or the pane separator.
Expected behavior
UI elements should not react to the mouse when the editor window is hidden behind another window.
I am experimenting a little, and compiling like this:
~/focus
❯ ~/Downloads/jai/bin/jai-linux -x64 first.jai - release
Works fine, but when opening a file, I can't scroll. That's a very strange bug to report -- I know, but it seems to be consistent.
Also, pressing j
on the keyboard, seems to replace the whole file by a bunch of i
:
I hope you can reproduce this.
❯ ~/Downloads/jai/bin/jai-linux -version
Version: beta 0.1.061, built on 16 April 2023.
Describe the bug
To Reproduce
Focus Version
0.1.10
When typing '/' in the file opener the top result in the list is selected. The bug is that there can be an exact match in the list but this directory is not opened. Basically, typing a slash should not autocomplete when there is an exact match.
IANAL, but I don't think you can just bundle the Segoe UI font like that. See here for more info: https://learn.microsoft.com/en-us/typography/fonts/font-faq
In particular:
How about Segoe UI? I love it and would like to include that in my non-Windows app or game. Is it available from Monotype?
No, as Segoe UI is both our user interface and corporate branding font, it is not available for use outside of Microsoft products on non-Windows platforms. However, we do have a Segoe-compatible open-source font you can use: Selawik.
I don't know. I'm definitely open to debate on this. I just have a sense that this feels wrong.
I often partially-type folder names then push Enter rather than use the arrow keys (then Enter) to select folders. "/" makes perfect sense as an alternative to Enter.
It is just this one particular case, when the box is blank, on Mac/Linux, the final root folder is always "/". So I find it "inconsistent" when I type "/" and it just selects the first folder, when "/" is a perfect name-match for the last folder in the list.
This could be an exception to the otherwise perfect rule. On Mac/Linux, we could simply select the "/" folder if it is present when that key is pressed. It is also consistent that this is the only time you will ever have this situation occur, so adding a special rule for this one case should not have odd side effects in theory.
Weird one: run Visual Studio (2022 here) and then run Focus, within ~10 seconds Focus.exe exits/crashes. Do that in the reverse order (Focus first, the VS)... no problem.
Describe the bug
When paths are compared (for example, to see if the config file has been updated) it is done with a simple ==
comparison. However, on windows filenames are not case sensitive so this is broken.
To Reproduce
Steps to reproduce the behavior:
Make a project and set its workspace folder to a different cased version of the path.
My fix for it is in this commit (it's pretty simple)
onelivesleft@95a1576
Describe the bug
Copying a section of the provided program.c
file causes crashes in Chrome and Focus, and not working in any other program.
To Reproduce
Steps to reproduce the behavior:
program.c
Alt+x
, then Navigate To File From Root
until you reach the file.#include <stdio.h>
#include <unistd.h>
#include <curses.h>
int main() {
cbreak();
echo();
int value;
scanf("%d", &value);
return 0;
}
Expected behavior
Copied text is handled correctly and does not cause crashes.
Screenshots
My pc is not in English so any screenshots might be confusing. Anyways, I don't think any visual aid is needed. I can provide if you want, though.
Additional context
I have set the environment variable FOCUS_LD_BACKEND
to Wayland
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.