This is a simple, interactive command-line calendar application written in Go. It displays a monthly calendar in the terminal and allows you to navigate through months and years using the arrow keys.
- Interactive Navigation: Use the left and right arrow keys to change months, and the up and down arrow keys to change years.
- Day Selection: Use the number keys (0-9) to select a day. The selected day is highlighted. Supports two-digit day selection.
- Clear Display: Uses ANSI escape codes to highlight the selected day, providing clear visual feedback.
- Clean Exit: Quit the application cleanly using 'q', Escape, or Ctrl+C.
- Terminal Multiplexer Compatible: Built using the
tcell
library, making it compatible with terminal multiplexers liketmux
andzellij
.
-
Build the application:
go build
-
Run the application:
./simple-cli-cal # Or whatever you named the executable
Alternatively you can use
go run
:go run calendar.go
-
Interact with the calendar:
- Arrow keys (←/→): Change the month.
- Arrow keys (↑/↓): Change the year.
- Number keys (0-9): Select a day.
q
: Quit the application.
main()
: The main entry point of the application. Handles initialization, the main event loop, and user input.printCalendar(year int, month time.Month, selectedDay int)
(usingkeyboard
library): Prints the calendar to standard output, formatting the output and highlighting the selected day. (This function is no longer used in thetcell
version).drawCalendar(s tcell.Screen, year int, month time.Month, selectedDay int)
(usingtcell
library): Draws the calendar onto thetcell
screen, handling all the visual rendering.drawString(s tcell.Screen, x, y int, style tcell.Style, text string)
(usingtcell
library): A helper function to draw text on thetcell
screen at a specific location with a given style.clearScreen()
(usingkeyboard
library): Clears the terminal screen. (This function is no longer used in thetcell
version).getTerminalSize()
(usingkeyboard
library): Not in use, kept for completeness.
github.com/gdamore/tcell/v2
: A low-level terminal manipulation library. Provides more robust input handling and terminal control than simpler libraries, making it compatible with terminal multiplexers. This is the recommended library for this application.
Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.