Skip to content

Commit

Permalink
[terminal] Screen: Fixes XTGETTCAP response to string requests and in…
Browse files Browse the repository at this point in the history
…valid numeric requests. Closes #582
  • Loading branch information
christianparpart committed Jan 11, 2022
1 parent f764fb6 commit 8465d4d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixes PTY write race condition.
- Fixes installation from `.deb` (missing terminfo dependency)
- Fixes `DECRC` with respect to `DECSTBM` enabled and `DECOM` being inverted interpreted.
- Fixes `XTGETTCAP` (#582).
- Improved VT backend performance (#342).
- Improved text selection behaviour.
- Adds preliminary implementation of `DA3` VT sequence.
Expand Down
4 changes: 2 additions & 2 deletions src/terminal/Capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ unsigned StaticDatabase::numericCapability(Code _cap) const
if (cap.code.code == _cap.code)
return cap.value;

return -1;
return npos;
}

string_view StaticDatabase::stringCapability(Code _cap) const
Expand All @@ -491,7 +491,7 @@ unsigned StaticDatabase::numericCapability(string_view _cap) const
if (tcap.name == _cap || tcap.code == _cap)
return tcap.value;

return -1;
return npos;
}

string_view StaticDatabase::stringCapability(string_view _cap) const
Expand Down
2 changes: 2 additions & 0 deletions src/terminal/Capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ namespace literals
class Database
{
public:
constexpr static inline unsigned npos = unsigned(-1);

virtual ~Database() = default;

virtual bool booleanCapability(Code _cap) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,7 @@ void Screen<T>::requestCapability(std::string_view _name)

if (booleanCapability(_name))
reply("\033P1+r{}\033\\", toHexString(_name));
else if (auto const value = numericCapability(_name); value >= 0)
else if (auto const value = numericCapability(_name); value != Database::npos)
{
auto hexValue = fmt::format("{:X}", value);
if (hexValue.size() % 2)
Expand Down
9 changes: 9 additions & 0 deletions src/terminal/Screen_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,15 @@ TEST_CASE("DECCRA.Left.intersecting", "[screen]")
}
// }}}

TEST_CASE("Screen.tcap.string", "[screen, tcap]")
{
using namespace terminal;
auto term = MockTerm(PageSize { LineCount(3), ColumnCount(5) }, LineCount(2));
auto& screen = term.screen;
screen.write("\033P+q687061\033\\"); // HPA
REQUIRE(e(term.replyData) == e("\033P1+r687061=1B5B2569257031256447\033\\"));
}

TEST_CASE("Sixel.simple", "[screen]")
{
auto const pageSize = PageSize { LineCount(10), ColumnCount(10) };
Expand Down

0 comments on commit 8465d4d

Please sign in to comment.