-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CP437 as optional display format in ASCII display for #20
- Loading branch information
1 parent
362f27b
commit 50c3d50
Showing
12 changed files
with
437 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "ascii.h" | ||
|
||
Ascii::Ascii() | ||
{ | ||
|
||
} | ||
|
||
QString Ascii::getName() { | ||
return "ASCII"; | ||
} | ||
|
||
QString Ascii::getDisplayChars(Frame frame, int offset) { | ||
QString frameString = ""; | ||
if (offset + 7 >= frame.size()) { | ||
// partial char | ||
frameString += '.'; | ||
} | ||
else { | ||
char byte = 0; | ||
for (int bit = 0; bit < 8; bit++) { | ||
byte <<= 1; | ||
if (frame.at(offset + bit)) { | ||
byte |= 0x01; | ||
} | ||
} | ||
if (isprint(byte)) { | ||
frameString += byte; | ||
} | ||
else { | ||
frameString += '.'; | ||
} | ||
} | ||
return frameString; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef ASCII_H | ||
#define ASCII_H | ||
|
||
#include "charmaker.h" | ||
|
||
class Ascii : public CharMaker | ||
{ | ||
public: | ||
Ascii(); | ||
QString getName() override; | ||
QString getDisplayChars(Frame frame, int offset) override; | ||
}; | ||
|
||
#endif // ASCII_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef CHARMAKER_H | ||
#define CHARMAKER_H | ||
|
||
#include "frame.h" | ||
#include <QString> | ||
|
||
class CharMaker { | ||
public: | ||
virtual ~CharMaker() | ||
{ | ||
} | ||
virtual QString getName() = 0; | ||
virtual QString getDisplayChars(Frame frame, int offset) = 0; | ||
}; | ||
|
||
#endif // CHARMAKER_H |
Oops, something went wrong.