Skip to content

Commit

Permalink
fixes #193 - custom key bindings may stop working after using dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Mar 24, 2024
1 parent a762c8c commit fe3453e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

#pragma once

#define NCHAT_VERSION "4.43"
#define NCHAT_VERSION "4.44"
2 changes: 1 addition & 1 deletion src/nchat.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH NCHAT "1" "March 2024" "nchat v4.43" "User Commands"
.TH NCHAT "1" "March 2024" "nchat v4.44" "User Commands"
.SH NAME
nchat \- ncurses chat
.SH SYNOPSIS
Expand Down
20 changes: 15 additions & 5 deletions src/uikeyconfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// uikeyconfig.cpp
//
// Copyright (c) 2019-2023 Kristofer Berggren
// Copyright (c) 2019-2024 Kristofer Berggren
// All rights reserved.
//
// nchat is distributed under the MIT license, see LICENSE for details.
Expand Down Expand Up @@ -332,10 +332,20 @@ int UiKeyConfig::GetKeyCode(const std::string& p_KeyName)

int UiKeyConfig::GetVirtualKeyCodeFromOct(const std::string& p_KeyOct)
{
int keyCode = ReserveVirtualKeyCode();
std::string keyStr = StrUtil::StrFromOct(p_KeyOct);
define_key(keyStr.c_str(), keyCode);
return keyCode;
static std::map<std::string, int> reservedVirtualKeyCodes;
auto it = reservedVirtualKeyCodes.find(p_KeyOct);
if (it != reservedVirtualKeyCodes.end())
{
return it->second;
}
else
{
int keyCode = ReserveVirtualKeyCode();
std::string keyStr = StrUtil::StrFromOct(p_KeyOct);
define_key(keyStr.c_str(), keyCode);
reservedVirtualKeyCodes[p_KeyOct] = keyCode;
return keyCode;
}
}

int UiKeyConfig::ReserveVirtualKeyCode()
Expand Down

0 comments on commit fe3453e

Please sign in to comment.