1 // -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; -*- 2 // (c) 2021 Henner Zeller <h.zeller@acm.org> 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation version 2. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <http://gnu.org/licenses/gpl-2.0.txt> 15 16 #ifndef ITERM2_CANVAS_H 17 #define ITERM2_CANVAS_H 18 19 #include "terminal-canvas.h" 20 #include "display-options.h" 21 22 namespace timg { 23 // Implements https://iterm2.com/documentation-images.html 24 class ITerm2GraphicsCanvas final : public TerminalCanvas { 25 public: 26 ITerm2GraphicsCanvas(BufferedWriteSequencer *ws, 27 const DisplayOptions &opts); 28 ~ITerm2GraphicsCanvas() override; 29 30 void Send(int x, int dy, const Framebuffer &framebuffer, 31 SeqType sequence_type, Duration end_of_frame) override; 32 33 private: 34 const DisplayOptions &options_; 35 36 char *RequestBuffer(int width, int height); 37 38 char *png_buf_ = nullptr; // Scratch buffer to encode PNG into 39 size_t png_buf_size_ = 0; 40 }; 41 } // namespace timg 42 #endif // ITERM2_CANVAS_H 43