* Performs view of given content. * @protected * @param {string} content * @return {void|Promise} Resolves when completed.
(content)
| 68 | * @return {void|Promise} Resolves when completed. |
| 69 | */ |
| 70 | async performView (content) { |
| 71 | const bytes = content.getBytes() |
| 72 | const format = this.getSettingValue('format') |
| 73 | |
| 74 | // Encode bytes to string |
| 75 | let string, charBits |
| 76 | switch (format) { |
| 77 | case 'hexadecimal': |
| 78 | string = ByteEncoder.hexStringFromBytes(bytes) |
| 79 | charBits = 4 |
| 80 | break |
| 81 | case 'binary': |
| 82 | string = ByteEncoder.binaryStringFromBytes(bytes) |
| 83 | charBits = 1 |
| 84 | } |
| 85 | |
| 86 | // Group result |
| 87 | const groupBits = this.getSettingValue('groupBits') |
| 88 | if (groupBits !== null) { |
| 89 | const groupChars = groupBits / charBits |
| 90 | string = StringUtil.chunk(string, groupChars).join(' ') |
| 91 | } |
| 92 | |
| 93 | // Show it |
| 94 | this.getView().setText(string) |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Triggered when the text has been changed inside the view. |
nothing calls this directly
no test coverage detected