Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.22', '1.23', '1.24']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: go mod tidy

- name: Run tests
run: go test -v ./...

- name: Build
run: go build -v ./...

- name: Test examples
run: |
cd examples/hello-world && go build -v
cd ../animation && go build -v
cd ../game && go build -v

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
101 changes: 101 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Run tests
run: go test -v ./...

- name: Build
run: go build -v ./...

- name: Generate changelog
id: changelog
run: |
# Get the current tag
current_tag=${GITHUB_REF#refs/tags/}
echo "current_tag=$current_tag" >> $GITHUB_OUTPUT

# Get previous tag
previous_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")

# Generate changelog between tags
if [ -n "$previous_tag" ]; then
echo "## What's Changed" > changelog.md
echo "" >> changelog.md
git log --pretty=format:"- %s (%h)" $previous_tag..$current_tag >> changelog.md
echo "" >> changelog.md
echo "" >> changelog.md
echo "**Full Changelog:** https://github.com/${{ github.repository }}/compare/$previous_tag...$current_tag" >> changelog.md
else
echo "## What's Changed" > changelog.md
echo "" >> changelog.md
echo "Initial release of TerminalEngineGo" >> changelog.md
echo "" >> changelog.md
git log --pretty=format:"- %s (%h)" >> changelog.md
fi

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.changelog.outputs.current_tag }}
name: Release ${{ steps.changelog.outputs.current_tag }}
body_path: changelog.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update CHANGELOG.md
run: |
current_tag=${{ steps.changelog.outputs.current_tag }}
current_date=$(date +%Y-%m-%d)

# Create or update CHANGELOG.md
if [ ! -f CHANGELOG.md ]; then
echo "# Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi

# Add new version to changelog
{
head -n 4 CHANGELOG.md
echo ""
echo "## [$current_tag] - $current_date"
echo ""
tail -n +5 changelog.md
echo ""
tail -n +5 CHANGELOG.md
} > CHANGELOG.md.tmp

mv CHANGELOG.md.tmp CHANGELOG.md

- name: Commit updated changelog
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md for ${{ steps.changelog.outputs.current_tag }}" || exit 0
git push origin HEAD:main
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Example binaries
examples/hello-world/hello-world
examples/animation/animation
examples/game/game

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Go workspace file
go.work

# Dependency directories (remove the comment below to include it)
# vendor/

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.1.1] - 2024-01-XX

### Added
- Initial release of TerminalEngineGo
- Core engine with Model-View-Update architecture
- Terminal input handling with support for arrow keys
- Flexible rendering system with double buffering
- Animation support with frame-based animations
- Localization support with JSON-based language files
- Alternate screen mode for full-screen applications
- Example applications demonstrating core features

### Features
- Event-driven architecture following The Elm Architecture pattern
- ANSI escape sequence support for terminal control
- Global renderer management
- Timer and tick message support
- Keyboard input abstraction
- Terminal size detection and handling
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 SkyVence

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# TerminalEngineGo

![Version](https://img.shields.io/github/v/tag/SkyVence/TerminalEngineGo?label=version&sort=semver)
![Go Version](https://img.shields.io/github/go-mod/go-version/SkyVence/TerminalEngineGo)
![License](https://img.shields.io/github/license/SkyVence/TerminalEngineGo)
![Build Status](https://img.shields.io/github/actions/workflow-status/SkyVence/TerminalEngineGo/release.yml)

A simple, elegant terminal game engine written in Go that provides a foundation for building interactive terminal applications and games.

## Features

- **Event-driven architecture** with Model-View-Update pattern
- **Terminal input handling** with support for arrow keys and special characters
- **Flexible rendering system** with double buffering and ANSI escape sequences
- **Animation support** with frame-based animations
- **Localization support** with JSON-based language files
- **Alternate screen mode** for full-screen applications
- **Simple API** that's easy to learn and use

## Installation

```bash
go get github.com/skyvence/TerminalEngineGo
```

## Quick Start

```go
package main

import (
"github.com/skyvence/TerminalEngineGo"
)

type model struct {
content string
}

func (m model) Init() engine.Msg {
return nil
}

func (m model) Update(msg engine.Msg) (engine.Model, engine.Cmd) {
switch msg := msg.(type) {
case engine.KeyMsg:
if msg.Rune == 'q' {
return m, func() engine.Msg { return engine.Quit() }
}
}
return m, nil
}

func (m model) View() string {
return "Hello, Terminal Engine! Press 'q' to quit.\n"
}

func main() {
m := model{content: "Hello World"}
p := engine.NewProgram(m)
p.Run()
}
```

## Documentation

For detailed documentation, see the [docs](./docs/) directory:

- [Getting Started](./docs/getting-started.md)
- [API Reference](./docs/api-reference.md)
- [Examples](./docs/examples.md)

## Examples

Check out the [examples](./examples/) directory for practical implementations:

- [Hello World](./examples/hello-world/) - Basic terminal application
- [Animation Demo](./examples/animation/) - Frame-based animation example
- [Game Example](./examples/game/) - Simple interactive game

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
Loading
Loading