| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // tape.hpp
- // cli
- //
- // Created by Sam Jaffe on 7/23/24.
- // Copyright © 2024 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <cstdint>
- #include <string>
- #include <vector>
- namespace cli {
- struct Tape {
- public:
- using callback_type = std::function<void(std::string)>;
- using value_type = std::string;
- using char_type = char;
-
- private:
- size_t negative_offset_{0};
- size_t cursor_offset_{0};
- std::vector<value_type> elements_{""};
- callback_type callback_;
- public:
- explicit Tape(callback_type const &callback) : Tape(1, callback) {}
- Tape(size_t n, callback_type const &callback);
-
- value_type const &get() const;
-
- void readch();
-
- private:
- value_type &get();
-
- void down();
- void up();
- void left();
- void right();
-
- void insert(char_type value);
- void erase();
- void clear();
- };
- }
|