10#ifndef THIRDPARTY_ESH_SHELLHISTORY_CPP_
11#define THIRDPARTY_ESH_SHELLHISTORY_CPP_
19: m_history{historyBuffer},
20 m_numberOfEntries{numberOfEntries},
27 if (command.empty() || m_history ==
nullptr)
31 int index = m_savedCommands % m_numberOfEntries;
32 std::copy_n(command.begin(), std::min(command.size(), m_lineSize - 1), m_history + index * m_lineSize);
33 m_history[index * m_lineSize + std::min(command.size(), m_lineSize - 1)] = 0;
34 m_index = ++m_savedCommands;
39 if (!(m_index <
static_cast<int32_t
>(m_savedCommands - m_numberOfEntries) || m_index == 0 || m_history ==
nullptr))
42 int index = m_index % m_numberOfEntries;
43 if (std::equal(m_history + index * m_lineSize, m_history + index * m_lineSize + m_lineSize, commandBuffer))
45 std::copy(m_history + index * m_lineSize, m_history + index * m_lineSize + m_lineSize, commandBuffer);
54 if (m_index == m_savedCommands || m_history ==
nullptr)
61 int index = m_index % m_numberOfEntries;
62 std::copy(m_history + index * m_lineSize, m_history + index * m_lineSize + m_lineSize, commandBuffer);
void insert(std::string_view command)
Inserts a command.
History(char *historyBuffer, size_t numberOfEntries, size_t lineSize)
Constructor.
void handleArrowUp(char commandBuffer[])
Performes a lookup based on an up-arrow key stroke.
void handleArrowDown(char commandBuffer[])
Performes a lookup based on an down-arrow key stroke.