GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tech/cxx_texteditors.cpp
Date: 2026-09-21 06:26:40
Exec Total Coverage
Lines: 62 67 92.5%
Functions: 20 22 90.9%
Branches: 11 20 55.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/tech/texteditors.hpp"
30 #include "gate/exceptions.hpp"
31
32 namespace gate
33 {
34 namespace tech
35 {
36
37 1 TextEditor::TextEditor(size_t width, size_t height)
38 {
39 1 const result_t res = gate_texteditor_create(&this->impl, width, height);
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_ERROR(res);
41 1 }
42 2 TextEditor::~TextEditor() noexcept
43 {
44 1 gate_texteditor_destroy(&this->impl);
45 1 }
46 3 gate_texteditor_t* TextEditor::c_impl() noexcept
47 {
48 3 return &this->impl;
49 }
50 gate_texteditor_t const* TextEditor::c_impl() const noexcept
51 {
52 return &this->impl;
53 }
54
55 1 void TextEditor::clear()
56 {
57 1 const result_t res = gate_texteditor_clear(&this->impl);
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_ERROR(res);
59 1 }
60 3 void TextEditor::insertChar(char_32_t chr)
61 {
62 3 const result_t res = gate_texteditor_insert_char(&this->impl, chr);
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 GATEXX_CHECK_EXCEPTION(res);
64 3 }
65 1 void TextEditor::insert(char const* data, size_t len)
66 {
67 1 const result_t res = gate_texteditor_insert(&this->impl, data, len);
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(res);
69 1 }
70 1 void TextEditor::deleteChar()
71 {
72 1 const result_t res = gate_texteditor_delete_char(&this->impl);
73
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(res);
74 1 }
75 1 void TextEditor::deleteBack()
76 {
77 1 const result_t res = gate_texteditor_delete_back(&this->impl);
78
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(res);
79 1 }
80 9 void TextEditor::move(MoveEnum direction)
81 {
82 9 const result_t res = gate_texteditor_move(&this->impl, static_cast<enumint_t>(direction));
83
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 GATEXX_CHECK_EXCEPTION(res);
84 8 }
85 1 void TextEditor::newLine()
86 {
87 1 const result_t res = gate_texteditor_new_line(&this->impl);
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(res);
89 1 }
90 3 void TextEditor::fixView()
91 {
92 3 const result_t res = gate_texteditor_fix_view(&this->impl);
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 GATEXX_CHECK_EXCEPTION(res);
94 3 }
95 3 size_t TextEditor::getLineCount() const
96 {
97 3 return gate_texteditor_get_line_count(&this->impl);
98 }
99 2 String TextEditor::getLineView(size_t line)
100 {
101 2 char const* ptr_text = NULL;
102
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 const size_t len_text = gate_texteditor_get_line_view(&this->impl, line, &ptr_text);
103 4 return String::createStatic(ptr_text, len_text);
104 }
105 3 TextEditor::StateEnum TextEditor::getState() const
106 {
107 3 const enumint_t state = gate_texteditor_get_state(&this->impl);
108 3 return static_cast<StateEnum>(state);
109 }
110 void TextEditor::setState(StateEnum newState)
111 {
112 gate_texteditor_set_state(&this->impl, static_cast<enumint_t>(newState));
113 }
114
115 1 size_t TextEditor::getWidth() const noexcept
116 {
117 1 return this->impl.window_width;
118 }
119 1 size_t TextEditor::getHeight() const noexcept
120 {
121 1 return this->impl.window_height;
122 }
123 1 size_t TextEditor::getLeftCol() const noexcept
124 {
125 1 return this->impl.window_start_col;
126 }
127 1 size_t TextEditor::getTopRow() const noexcept
128 {
129 1 return this->impl.window_start_row;
130 }
131 4 size_t TextEditor::getRow() const noexcept
132 {
133 4 return this->impl.cur_row;
134 }
135 2 size_t TextEditor::getCol() const noexcept
136 {
137 2 return this->impl.cur_col;
138 }
139
140
141 } // end of namespace sys
142 } // end of namespace gate
143