Skip to content

Commit

Permalink
feat: added homescreen for the editor, and made it the fallback input…
Browse files Browse the repository at this point in the history
… file if no file was passed as argument
  • Loading branch information
MassiGy committed Jun 14, 2024
1 parent da394da commit ac4b819
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ SHARED_DIR:=${HOME}/.local/share/${BINARY_NAME}-${VERSION}
AUTHOR:="Massiles Ghernaout"

info:
bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))

@echo "Project: ${BINARY_NAME}@${VERSION}"
@echo "Author: ${AUTHOR}"

Expand All @@ -16,6 +19,10 @@ bin:

binstatic:
rm -rf bin/*

bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))

@echo "Building a static executable..."
CGO_ENABLED=0 go build -a -tags netgo,osusergo -ldflags "-X main.version=${VERSION} -X main.binary_name=${BINARY_NAME} -extldflags '-static -s -w'" -o bin/${BINARY_NAME} cmd/main.go

Expand All @@ -26,6 +33,10 @@ runsrc:
ENV=dev DEBUG=true go run ./cmd/main.go

make_bin_shared:
bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))
$(eval SHARED_DIR=${HOME}/.local/share/${BINARY_NAME}-${VERSION})

cp $(shell pwd)/bin/${BINARY_NAME} ${SHARED_DIR}/${BINARY_NAME};
@echo "The ${BINARY_NAME} binary file can be found in ${SHARED_DIR}";
@echo ""
Expand All @@ -37,11 +48,6 @@ setup:
@echo ""
@echo "Setting up the config and local shared directories, and the appropriate files."

bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))
$(eval CONFIG_DIR=${HOME}/.config/${BINARY_NAME}-${VERSION})
$(eval SHARED_DIR=${HOME}/.local/share/${BINARY_NAME}-${VERSION})

bash ./scripts/setup_config_dir.sh
bash ./scripts/setup_shared_dir.sh

Expand All @@ -50,8 +56,17 @@ setup:
install: setup make_bin_shared

rm_local_bin:
bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))
$(eval SHARED_DIR=${HOME}/.local/share/${BINARY_NAME}-${VERSION})

rm -rf ${SHARED_DIR}/${BINARY_NAME}

uninstall: rm_local_bin
bash ./scripts/update_version_using_git_tags.sh
$(eval VERSION=$(shell cat ./VERSION))
$(eval CONFIG_DIR=${HOME}/.config/${BINARY_NAME}-${VERSION})
$(eval SHARED_DIR=${HOME}/.local/share/${BINARY_NAME}-${VERSION})

rm -rf ${CONFIG_DIR}
rm -rf ${SHARED_DIR}
16 changes: 12 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// constants
var QUIT bool = false
var WRAP bool = true //TODO: add this to a config file
var WRAP_AFTER int = 60
var WRAP_AFTER int = 80
var ROWS, COLS int
var SAVE_TO_FILE_MAX_ERROR_COUNT int = 3
var UNKOWN_SOURCE_FILENAME string = "nofile"
Expand Down Expand Up @@ -715,9 +715,17 @@ func run_editor() {
source_file = os.Args[1]
read_file(source_file)
} else {
source_file = UNKOWN_SOURCE_FILENAME
info_message = "Input file messing."
textBuffer = append(textBuffer, []rune{})
about_file_path := fmt.Sprintf("%s/.config/%s-%s/about", os.Getenv("HOME"), binary_name, version)

// check for about file existance
if _, err := os.Stat(about_file_path); err == nil {
source_file = about_file_path
read_file(source_file)
} else {
source_file = UNKOWN_SOURCE_FILENAME
info_message = "Input file messing."
textBuffer = append(textBuffer, []rune{})
}
}
currentCol = LINE_NUMBER_COL_WIDTH
currentRow = 0
Expand Down
Binary file removed eddy_v0.1.0_snapshot.png
Binary file not shown.
Binary file added eddy_v0.1.4_snapshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/setup_about_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ ! -f $HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/targets ]; then
echo "Creating $HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/about file";

figlet -W "eddy" > $HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/about;
figlet -W " eddy" > $HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/about;
echo "
Eddy is a vim like editor, meaning that we have multiple motions and
Expand Down Expand Up @@ -52,5 +52,5 @@ if [ ! -f $HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/targets ]; then
ALL PgUp page up goto top of file.
ALL PgDown page down goto end of file.
">$HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/about;
">>$HOME/.config/$(cat ./BINARY_NAME)-$(cat ./VERSION)/about;
fi
2 changes: 0 additions & 2 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Basic
- Add a prompt like feature where we can get user input.
- Add a homescreen to the editor showing all the shortcuts.
- Maybe set fallback file to stdin if no filename is passed.

# Advanced
- Add undo/redo capabilities.
Expand Down

0 comments on commit ac4b819

Please sign in to comment.