Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Post committed Mar 16, 2023
1 parent 0800416 commit 36f86ce
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 19 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Mako
### A terminal based IDE/text editor built with the Textual library

## Planned Features
- Syntax highlighting (via Pygments)
- LSP autosuggestion
- LSP linting/diagnostics
- Auto formmatting
- Fuzzy finder
- File tree
- Multiple cursors
- Tree-sitter integration
- File/project search/replace
- Tabs
- View splitting (horizontal and vertical)
- Auto save
- Project focused with ability to edit one off files
- Scratch files
- Run configurations
- Git integration
- Themes (Pygments themes and Textual css)
- Markdown live preview
- Log tailing
- Built in terminal (via Pyte)
- System clipboard integration
- Command mode (ctrl+space)
- Select mode (ctrl+w)
- auto brackets/surround
- Easy configuration
- Simple key remapping
- An optional VIM style of modes/keybinds


## Design philosophy
- The default will be EDIT MODE (analogous to INSERT in VIM)
- COMMAND MODE for quickly accessing common commands (analogous to NORMAL in VIM)
- SELECT MODE for precision selections/manipulations (beyond holding shift and using
arrow keys), (analogous to VISUAL in VIM)
36 changes: 35 additions & 1 deletion mako/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
from rich.syntax import Syntax


def default_brackets() -> dict[str, str]:
return {
"[": "]",
"(": ")",
"{": "}",
"'": "'",
'"': '"',
"<": ">",
}


@dataclass
class Formatter:
command: str = ""
Expand All @@ -24,12 +35,35 @@ class Language:
line_numbers: bool = True
auto_indent: bool = True
auto_brackets: bool = True
bracket_pairs: str = "[],(),{},'',\"\",<>"
bracket_pairs: dict[str] = field(default_factory=default_brackets)


@dataclass
class EditMode:
up: str = "up"


@dataclass
class CommandMode:
up: str = "up"


@dataclass
class SelectMode:
up: str = "up"


@dataclass
class Keybinds:
edit: EditMode = field(default_factory=EditMode)
command: CommandMode = field(default_factory=CommandMode)
select: SelectMode = field(default_factory=SelectMode)


@dataclass
class Config:
languages: dict[str, Language] = field(default_factory=dict)
keybinds: Keybinds = field(default_factory=Keybinds)
auto_save: bool = True
format_on_save: bool = True
highlight_line: bool = True
Expand Down
33 changes: 16 additions & 17 deletions mako/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
from pathlib import Path

import pyperclip
from rich.cells import get_character_cell_size
from rich.console import RenderableType
from rich.syntax import Syntax
from rich.text import Text
from rich.traceback import Traceback
from textual.app import ComposeResult
from textual.events import Click, Key, Paste
from textual.events import Key, Paste
from textual.message import Message
from textual.reactive import reactive
from textual.widgets import Placeholder, Static
Expand Down Expand Up @@ -292,21 +291,21 @@ def on_paste(self, event: Paste) -> None:
self.insert_text_at_cursor(event.text)
event.stop()

def on_click(self, event: Click) -> None:
offset = event.get_content_offset(self)
if offset is None:
return
event.stop()
click_x = offset.x + self.view_position
cell_offset = 0
_cell_size = get_character_cell_size
for index, char in enumerate(self.value):
if cell_offset >= click_x:
self.cursor_column = index
break
cell_offset += _cell_size(char)
else:
self.cursor_column = len(self.value)
# def on_click(self, event: Click) -> None:
# offset = event.get_content_offset(self)
# if offset is None:
# return
# event.stop()
# click_x = offset.x + self.view_position
# cell_offset = 0
# _cell_size = get_character_cell_size
# for index, char in enumerate(self.value):
# if cell_offset >= click_x:
# self.cursor_column = index
# break
# cell_offset += _cell_size(char)
# else:
# self.cursor_column = len(self.value)

def insert_return_char(self) -> None:
lines = self.value.split("\n")
Expand Down
12 changes: 11 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies = [
"pyte>=0.8.1",
"sansio-lsp-client>=0.10.0",
"levenshtein>=0.20.9",
"tree-sitter>=0.20.1",
]
requires-python = ">=3.11"
license = {text = "MIT"}
Expand Down

0 comments on commit 36f86ce

Please sign in to comment.