Skip to content

Durkluf/simple-cli-calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple CLI Calendar

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.

Features

  • 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 like tmux and zellij.

Usage

  1. Build the application:

    go build
  2. Run the application:

    ./simple-cli-cal  # Or whatever you named the executable

    Alternatively you can use go run:

      go run calendar.go
  3. 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.

Code Structure

  • 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) (using keyboard library): Prints the calendar to standard output, formatting the output and highlighting the selected day. (This function is no longer used in the tcell version).
  • drawCalendar(s tcell.Screen, year int, month time.Month, selectedDay int) (using tcell library): Draws the calendar onto the tcell screen, handling all the visual rendering.
  • drawString(s tcell.Screen, x, y int, style tcell.Style, text string) (using tcell library): A helper function to draw text on the tcell screen at a specific location with a given style.
  • clearScreen() (using keyboard library): Clears the terminal screen. (This function is no longer used in the tcell version).
  • getTerminalSize() (using keyboard library): Not in use, kept for completeness.

Dependencies

  • 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.

Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages