Skip to content
Snippets Groups Projects
Commit 07f90cc2 authored by tanguy.cavagna's avatar tanguy.cavagna :desktop:
Browse files

Initial commit with basic ncurses terminal

parents
No related branches found
No related tags found
No related merge requests found
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: 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
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
---
bin/
.vscode/
\ No newline at end of file
Makefile 0 → 100644
# see https://yuukidach.github.io/2019/08/05/makefile-learning/
# Variable setup
CC:=gcc
CFLAGS:=-g -Ofast -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11
LIBS:=-lm -lncurses
BIN = bin
# Get source and object
SRCS = $(filter-out $(wildcard */*_tests.c */*test.c */*tests.c */*_test.c), $(wildcard *.c */*.c))
OBJS = $(addprefix $(BIN)/, $(SRCS:.c=.o))
SRCS_TEST = $(filter-out $(wildcard main.c */main.c gfx/*), $(wildcard *.c */*.c))
OBJS_TEST = $(addprefix $(BIN)/, $(SRCS_TEST:.c=.o))
# Create the target
main: $(OBJS)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^ $(LIBS) $(LDFLAGS)
./$(BIN)/$@
# Convert the source in object, but before all, run `$(BIN)` aka mkdir
$(BIN)/%.o: %.c
mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $< $(LDFLAGS)
# Echo the source and object values
help:
@echo "src: $(SRCS)"
@echo "obj: $(OBJS)"
@echo "obj_test: $(OBJ_TEST)"
clean:
rm -rf $(BIN)
.PHONY: test-draw help clean main
#include "cli.h"
#include <ncurses.h>
//==========================
// PRIVATE
//==========================
//==========================
// PUBLIC
//==========================
void print_center(char *text) {
int padlen = (TERMINAL_WIDTH - strlen(text)) / 2;
printw("%*s%s%*s\n", padlen, "", text, padlen, "");
}
\ No newline at end of file
#ifndef CLI_H_
#define CLI_H_
#include <stdio.h>
#include <string.h>
#define TERMINAL_WIDTH 120
/**
* @brief Print center text
*
* @param text
*/
void print_center(char *text);
#endif
\ No newline at end of file
main.c 0 → 100644
#include "cli/cli.h"
#include "ui/ui.h"
#include "wordle/wordle.h"
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
init_term();
getch();
cleanup_term();
return EXIT_SUCCESS;
}
\ No newline at end of file
ui/ui.c 0 → 100644
#include "ui.h"
WINDOW *ui_window = NULL;
void set_colors() {
init_pair(GREEN_PAIR, COLOR_GREEN, COLOR_BLACK);
init_pair(ORANGE_PAIR, COLOR_YELLOW, COLOR_BLACK);
}
bool init_term() {
ui_window = initscr();
noecho();
if (ui_window == NULL)
return false;
start_color();
if (!has_colors() || !can_change_color()) {
printf("Warning. Your terminal can't handle this program.\n");
return false;
}
set_colors();
return true;
}
void cleanup_term() {
delwin(ui_window);
endwin();
refresh();
}
\ No newline at end of file
ui/ui.h 0 → 100644
#ifndef UI_H_
#define UI_H_
#include <ncurses.h>
#include <stdbool.h>
#define GREEN_PAIR 1
#define ORANGE_PAIR 2
/**
* @brief Initialize the terminal
*
* @return true
* @return false
*/
bool init_term();
/**
* @brief Cleanup the terminal
*
*/
void cleanup_term();
#endif
\ No newline at end of file
#include "wordle.h"
//==========================
// PRIVATE
//==========================
//==========================
// PUBLIC
//==========================
\ No newline at end of file
#ifndef WORDLE_H_
#define WORDLE_H_
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment