Multiple changes committed:
- Add .clang-format - Rename map.d/* to maps/* - Refactor maze.c
This commit is contained in:
225
.clang-format
Normal file
225
.clang-format
Normal file
@@ -0,0 +1,225 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAfterAttributes: Never
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
...
|
||||
|
||||
138
maze.c
138
maze.c
@@ -15,28 +15,31 @@
|
||||
#define UP 3
|
||||
|
||||
typedef struct termios tstate_t;
|
||||
|
||||
typedef uint8_t dir_t;
|
||||
|
||||
typedef struct entity_t {
|
||||
size_t X;
|
||||
size_t Y;
|
||||
} entity_t;
|
||||
|
||||
typedef struct maze_t {
|
||||
size_t X_SIZE;
|
||||
size_t Y_SIZE;
|
||||
size_t P_X_CORD;
|
||||
size_t P_Y_CORD;
|
||||
size_t S_X_CORD;
|
||||
size_t S_Y_CORD;
|
||||
size_t F_X_CORD;
|
||||
size_t F_Y_CORD;
|
||||
size_t SIZE_X;
|
||||
size_t SIZE_Y;
|
||||
entity_t *PLAYER;
|
||||
entity_t *START;
|
||||
entity_t *FINISH;
|
||||
uint8_t **PNTR;
|
||||
} maze_t;
|
||||
|
||||
tstate_t TSTATE;
|
||||
size_t TERM_COL;
|
||||
size_t TERM_ROW;
|
||||
maze_t *MAZE;
|
||||
|
||||
bool QUIT = false;
|
||||
bool WINSTATE = false;
|
||||
|
||||
size_t TERM_COL;
|
||||
size_t TERM_ROW;
|
||||
|
||||
void get_term_size() {
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
@@ -44,8 +47,8 @@ void get_term_size() {
|
||||
TERM_COL = w.ws_col;
|
||||
}
|
||||
|
||||
void exit_on_inadequate_space() {
|
||||
if (TERM_COL < 2 * MAZE->X_SIZE || TERM_ROW < MAZE->Y_SIZE) {
|
||||
void term_too_small_handler() {
|
||||
if (TERM_COL < 2 * MAZE->SIZE_X || TERM_ROW < MAZE->SIZE_Y) {
|
||||
printf("Terminal is too small to display the whole maze.\n\
|
||||
Either make the terminal window bigger, or use a smaller maze map.\n");
|
||||
exit(0);
|
||||
@@ -72,65 +75,75 @@ void get_maze_size(const char *path) {
|
||||
}
|
||||
}
|
||||
|
||||
MAZE->X_SIZE = x_cnt;
|
||||
MAZE->Y_SIZE = y_cnt;
|
||||
MAZE->SIZE_X = x_cnt;
|
||||
MAZE->SIZE_Y = y_cnt;
|
||||
}
|
||||
|
||||
#define restore_cursor() printf("\033[u")
|
||||
#define save_cursor() printf("\033[s")
|
||||
#define zero_cursor() printf("\033[0;0H"); fflush(stdout)
|
||||
#define zero_cursor() \
|
||||
printf("\033[0;0H"); \
|
||||
fflush(stdout)
|
||||
|
||||
void move(dir_t dir) {
|
||||
switch (dir) {
|
||||
case 1:
|
||||
if (MAZE->P_X_CORD != 0 && MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD - 1] != 1) {
|
||||
if (MAZE->P_X_CORD == MAZE->S_X_CORD && MAZE->P_Y_CORD == MAZE->S_Y_CORD) {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 2;
|
||||
if (MAZE->PLAYER->X != 0 &&
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X - 1] != 1) {
|
||||
if (MAZE->PLAYER->X == MAZE->START->X &&
|
||||
MAZE->PLAYER->Y == MAZE->START->Y) {
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 2;
|
||||
} else {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 0;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 0;
|
||||
}
|
||||
--MAZE->P_X_CORD;
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 4;
|
||||
--MAZE->PLAYER->X;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 4;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (MAZE->P_Y_CORD != MAZE->Y_SIZE - 1 && MAZE->PNTR[MAZE->P_Y_CORD + 1][MAZE->P_X_CORD] != 1) {
|
||||
if (MAZE->P_X_CORD == MAZE->S_X_CORD && MAZE->P_Y_CORD == MAZE->S_Y_CORD) {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 2;
|
||||
if (MAZE->PLAYER->Y != MAZE->SIZE_Y - 1 &&
|
||||
MAZE->PNTR[MAZE->PLAYER->Y + 1][MAZE->PLAYER->X] != 1) {
|
||||
if (MAZE->PLAYER->X == MAZE->START->X &&
|
||||
MAZE->PLAYER->Y == MAZE->START->Y) {
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 2;
|
||||
} else {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 0;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 0;
|
||||
}
|
||||
++MAZE->P_Y_CORD;
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 4;
|
||||
++MAZE->PLAYER->Y;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 4;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (MAZE->P_Y_CORD != 0 && MAZE->PNTR[MAZE->P_Y_CORD - 1][MAZE->P_X_CORD] != 1) {
|
||||
if (MAZE->P_X_CORD == MAZE->S_X_CORD && MAZE->P_Y_CORD == MAZE->S_Y_CORD) {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 2;
|
||||
if (MAZE->PLAYER->Y != 0 &&
|
||||
MAZE->PNTR[MAZE->PLAYER->Y - 1][MAZE->PLAYER->X] != 1) {
|
||||
if (MAZE->PLAYER->X == MAZE->START->X &&
|
||||
MAZE->PLAYER->Y == MAZE->START->Y) {
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 2;
|
||||
} else {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 0;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 0;
|
||||
}
|
||||
--MAZE->P_Y_CORD;
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 4;
|
||||
--MAZE->PLAYER->Y;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (MAZE->P_X_CORD != MAZE->X_SIZE - 1 && MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD + 1] != 1) {
|
||||
if (MAZE->P_X_CORD == MAZE->S_X_CORD && MAZE->P_Y_CORD == MAZE->S_Y_CORD) {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 2;
|
||||
if (MAZE->PLAYER->X != MAZE->SIZE_X - 1 &&
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X + 1] != 1) {
|
||||
if (MAZE->PLAYER->X == MAZE->START->X &&
|
||||
MAZE->PLAYER->Y == MAZE->START->Y) {
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 2;
|
||||
} else {
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 0;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 0;
|
||||
}
|
||||
++MAZE->P_X_CORD;
|
||||
MAZE->PNTR[MAZE->P_Y_CORD][MAZE->P_X_CORD] = 4;
|
||||
++MAZE->PLAYER->X;
|
||||
MAZE->PNTR[MAZE->PLAYER->Y][MAZE->PLAYER->X] = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void free_map() {
|
||||
for (size_t y_cord = 0; y_cord < MAZE->Y_SIZE; ++y_cord) {
|
||||
for (size_t y_cord = 0; y_cord < MAZE->SIZE_Y; ++y_cord) {
|
||||
free(MAZE->PNTR[y_cord]);
|
||||
}
|
||||
free(MAZE->PNTR);
|
||||
@@ -139,10 +152,13 @@ void free_map() {
|
||||
|
||||
void alloc_maze_buffer(const char *path) {
|
||||
MAZE = (maze_t *)malloc(sizeof(maze_t));
|
||||
MAZE->PLAYER = (entity_t *)malloc(sizeof(entity_t));
|
||||
MAZE->START = (entity_t *)malloc(sizeof(entity_t));
|
||||
MAZE->FINISH = (entity_t *)malloc(sizeof(entity_t));
|
||||
get_maze_size(path);
|
||||
MAZE->PNTR = (uint8_t **)malloc(MAZE->Y_SIZE * sizeof(uint8_t *));
|
||||
for (size_t y_cord = 0; y_cord < MAZE->Y_SIZE; ++y_cord) {
|
||||
MAZE->PNTR[y_cord] = (uint8_t *)malloc(MAZE->X_SIZE * sizeof(uint8_t));
|
||||
MAZE->PNTR = (uint8_t **)malloc(MAZE->SIZE_Y * sizeof(uint8_t *));
|
||||
for (size_t y_cord = 0; y_cord < MAZE->SIZE_Y; ++y_cord) {
|
||||
MAZE->PNTR[y_cord] = (uint8_t *)malloc(MAZE->SIZE_X * sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,13 +179,13 @@ void load_maze_to_buffer(const char *path) {
|
||||
++y_cord;
|
||||
continue;
|
||||
} else if ('4' == cur) {
|
||||
MAZE->P_X_CORD = x_cord;
|
||||
MAZE->P_Y_CORD = y_cord;
|
||||
MAZE->S_X_CORD = x_cord;
|
||||
MAZE->S_Y_CORD = y_cord;
|
||||
MAZE->PLAYER->X = x_cord;
|
||||
MAZE->PLAYER->Y = y_cord;
|
||||
MAZE->START->X = x_cord;
|
||||
MAZE->START->Y = y_cord;
|
||||
} else if ('3' == cur) {
|
||||
MAZE->F_X_CORD = x_cord;
|
||||
MAZE->F_Y_CORD = y_cord;
|
||||
MAZE->FINISH->X = x_cord;
|
||||
MAZE->FINISH->Y = y_cord;
|
||||
}
|
||||
MAZE->PNTR[y_cord][x_cord] = (uint8_t)(cur - (char)'0');
|
||||
++x_cord;
|
||||
@@ -179,14 +195,14 @@ void load_maze_to_buffer(const char *path) {
|
||||
void print() {
|
||||
const char sprites[] = " H*XO";
|
||||
save_cursor();
|
||||
for (size_t y_cord = 0; y_cord < MAZE->Y_SIZE; ++y_cord) {
|
||||
for (size_t x_cord = 0; x_cord < MAZE->X_SIZE; ++x_cord) {
|
||||
for (size_t y_cord = 0; y_cord < MAZE->SIZE_Y; ++y_cord) {
|
||||
for (size_t x_cord = 0; x_cord < MAZE->SIZE_X; ++x_cord) {
|
||||
putchar(sprites[MAZE->PNTR[y_cord][x_cord]]);
|
||||
if (x_cord < MAZE->X_SIZE - 1) {
|
||||
if (x_cord < MAZE->SIZE_X - 1) {
|
||||
putchar(' ');
|
||||
}
|
||||
}
|
||||
if (y_cord < MAZE->Y_SIZE - 1) {
|
||||
if (y_cord < MAZE->SIZE_Y - 1) {
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
@@ -203,7 +219,7 @@ void clear() {
|
||||
for (size_t x_cord = 0; x_cord < TERM_COL; ++x_cord) {
|
||||
putchar(' ');
|
||||
}
|
||||
if (y_cord < MAZE->Y_SIZE - 1) {
|
||||
if (y_cord < MAZE->SIZE_Y - 1) {
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
@@ -211,7 +227,8 @@ void clear() {
|
||||
}
|
||||
|
||||
void check_win() {
|
||||
if (MAZE->P_Y_CORD == MAZE->F_Y_CORD && MAZE->P_X_CORD == MAZE->F_X_CORD) {
|
||||
if (MAZE->PLAYER->Y == MAZE->FINISH->Y &&
|
||||
MAZE->PLAYER->X == MAZE->FINISH->X) {
|
||||
WINSTATE = true;
|
||||
}
|
||||
}
|
||||
@@ -277,13 +294,14 @@ void set_term_raw() {
|
||||
|
||||
atexit(&set_term_def); // Revert to canonical mode when exiting the program
|
||||
// atext() from <stdlib.h>
|
||||
raw.c_lflag &= ~(ECHO | ICANON); // Turn off canonical mode
|
||||
raw.c_lflag &=
|
||||
~(ECHO | ICANON); // Turn off canonical mode
|
||||
// Turn off ECHO mode so that keyboard is not
|
||||
// printing to terminal
|
||||
// ICANON and ECHO is bitflag. ~ is binary NOT operator
|
||||
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); // Set the terminal to be in raw mode
|
||||
// tcsetattr() from <termios.h>
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); // Set the terminal to be in raw
|
||||
// mode tcsetattr() from <termios.h>
|
||||
}
|
||||
|
||||
void set_term_def() {
|
||||
@@ -294,7 +312,7 @@ int main(int argc, char *argv[]) {
|
||||
if (argc > 1 && argc < 3) {
|
||||
get_term_size();
|
||||
alloc_maze_buffer(argv[1]);
|
||||
exit_on_inadequate_space();
|
||||
term_too_small_handler();
|
||||
load_maze_to_buffer(argv[1]);
|
||||
|
||||
pthread_t update_pid, capture_pid;
|
||||
|
||||
Reference in New Issue
Block a user