MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / OnKeyDown

Method OnKeyDown

WinArk/HexControl.cpp:160–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160LRESULT CHexControl::OnKeyDown(UINT, WPARAM wParam, LPARAM, BOOL&) {
161 if (m_Buffer == nullptr)
162 return 0;
163
164 auto current = m_CaretOffset;
165 bool abortEdit = false;
166 bool shift = ::GetKeyState(VK_SHIFT) & 0x80;
167 bool alt = ::GetKeyState(VK_CONTROL) & 0x80;
168
169 bool redraw = false;
170
171 if (shift) {
172 if (m_Selection.IsEmpty()) {
173 // �
174 m_Selection.SetAnchor(m_CaretOffset);
175 }
176 }
177
178 switch (wParam) {
179 case VK_BACK:
180 if (m_Selection.IsEmpty()) {
181 m_Buffer->Delete(m_CaretOffset - 1, m_DataSize);
182 m_CaretOffset--;
183 }
184 else {
185 m_Buffer->Delete(m_Selection.GetOffset(), m_Selection.GetLength());
186 }
187 RedrawWindow();
188 m_NotifyData.hdr.code = HCN_SIZECHANGED;
189 SendNotify(&m_NotifyData);
190 return 0;
191
192 case VK_DELETE:
193 if (m_Selection.IsEmpty()) {
194 m_Buffer->Delete(m_CaretOffset, m_DataSize);
195 }
196 else {
197 // ɾ��ѡ�е�����
198 m_Buffer->Delete(m_Selection.GetOffset(), m_Selection.GetLength());
199 }
200 RedrawWindow();
201 m_NotifyData.hdr.code = HCN_SIZECHANGED;
202 SendNotify(&m_NotifyData);
203 return 0;
204
205 case VK_ESCAPE:
206 if (m_EditDigits > 0)
207 abortEdit = true;
208 break;
209
210 case VK_DOWN:
211 if (m_CaretOffset + m_BytesPerLine < m_Buffer->GetSize())
212 m_CaretOffset += m_BytesPerLine;
213 else
214 m_CaretOffset = m_Buffer->GetSize();
215 break;
216
217 case VK_UP:

Callers

nothing calls this directly

Calls 9

IsEmptyMethod · 0.80
SetAnchorMethod · 0.80
GetOffsetMethod · 0.80
SetBoxMethod · 0.80
GetAnchorMethod · 0.80
SetSimpleMethod · 0.80
DeleteMethod · 0.45
GetLengthMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected