Skip to content

Commit

Permalink
Implements #101
Browse files Browse the repository at this point in the history
  • Loading branch information
RMichelsen committed Nov 8, 2023
1 parent 37fd670 commit 7b24b7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Nvy can be started with the following flags:
- `--position=<x>,<y>` to start with a given position, e.g. `--position=500,200`
- `--geometry=<cols>x<rows>` to start with a given number of rows and columns, e.g. `--geometry=80x25`
- `--disable-ligatures` to disable font ligatures
- `--disable-fullscreen` to disable toggling fullscreen with Alt+Enter
- `--linespace-factor=<float>` to scale the line spacing by a floating point factor, e.g. `--linespace-factor=1.2`

## Extra Features
Expand Down
9 changes: 7 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct Context {
GridSize start_grid_size;
bool start_maximized;
bool start_fullscreen;
bool disable_fullscreen;
HWND hwnd;
Nvim *nvim;
Renderer *renderer;
Expand Down Expand Up @@ -200,7 +201,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN: {
// Special case for <ALT+ENTER> (fullscreen transition)
if (((GetKeyState(VK_LMENU) & 0x80) != 0) && wparam == VK_RETURN) {
if (!context->disable_fullscreen && ((GetKeyState(VK_LMENU) & 0x80) != 0) && wparam == VK_RETURN) {
ToggleFullscreen(hwnd, context);
}
else if (((GetKeyState(VK_LMENU) & 0x80) != 0) && wparam == VK_F4) {
Expand Down Expand Up @@ -407,6 +408,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, PWSTR p_cmd_lin
bool start_maximized = false;
bool start_fullscreen = false;
bool disable_ligatures = false;
bool disable_fullscreen = false;
float linespace_factor = 1.0f;
int64_t rows = 0;
int64_t cols = 0;
Expand All @@ -430,6 +432,9 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, PWSTR p_cmd_lin
else if(!wcscmp(cmd_line_args[i], L"--disable-ligatures")) {
disable_ligatures = true;
}
else if(!wcscmp(cmd_line_args[i], L"--disable-fullscreen")) {
disable_fullscreen = true;
}
else if(!wcsncmp(cmd_line_args[i], L"--geometry=", wcslen(L"--geometry="))) {
wchar_t *end_ptr;
cols = wcstol(&cmd_line_args[i][11], &end_ptr, 10);
Expand Down Expand Up @@ -489,7 +494,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, PWSTR p_cmd_lin
},
.start_maximized = start_maximized,
.start_fullscreen = start_fullscreen,

.disable_fullscreen = disable_fullscreen,
.nvim = &nvim,
.renderer = &renderer,
.saved_window_placement = WINDOWPLACEMENT { .length = sizeof(WINDOWPLACEMENT) }
Expand Down

0 comments on commit 7b24b7e

Please sign in to comment.