Compare commits

..

10 Commits

Author SHA1 Message Date
Gustavo Henrique Santos Souza de Miranda f2fc60300f Merge branch 'staging' into development
Merged Staging to the Development Branch
2025-07-12 19:26:00 -03:00
Gustavo Henrique Santos Souza de Miranda 6dc2c01325 Revert "Update README.md"
This reverts commit 60311bc714.
2025-07-12 12:41:20 -03:00
Gustavo Henrique Santos Souza de Miranda 860fee2d19 Revert "Fixed the new entry creation flow by prompting for a title if none is set."
This reverts commit b704a524
2025-07-12 12:33:24 -03:00
Gustavo Henrique Santos Souza de Miranda fce47db0f8 Resolved the conflicts 2025-07-12 12:24:37 -03:00
Gustavo Henrique Santos Souza de Miranda 6ab35e680d Merge branch 'fix/create-a-new-entry-on-open' into development
Changed the behaviour to create a new entry when a diary is open a
2025-07-12 12:14:17 -03:00
Gustavo Henrique Santos Souza de Miranda de0e415ee2 Merge branch 'fix/binding-not-working' into development
Fixed the Footer to work properly with clicking too.k
2025-07-08 01:21:13 -03:00
Gustavo Henrique Santos Souza de Miranda f42d15048c Merge branch 'fix/status-not-updating' into development
Fixed the document status to properly change when the user edit something thus warning the document is not saved.nijthen
2025-07-08 00:44:11 -03:00
Gustavo Henrique Santos Souza de Miranda 40104db405 Merge branch 'feat/added-licenses-from-deps' into development
Added the licenses from the dependences used by the application
2025-07-08 00:36:25 -03:00
Gustavo Henrique Miranda d13750f725
Merge pull request #23 from gmbrax/fix/wrong-database-access
Fix/wrong database access
2025-07-06 03:28:27 -03:00
Gustavo Henrique Miranda 0b9b3c8cf0
Merge pull request #22 from gmbrax/fix/binding-not-working
Merging fix/binding-not-working into development
2025-07-06 03:11:17 -03:00
2 changed files with 56 additions and 82 deletions

View File

@ -25,7 +25,7 @@ structured and accessible format.
To install the application you must issue the command: To install the application you must issue the command:
```bash ```bash
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple Pilgrim pip install pilgrim
``` ```
## Usage ## Usage

View File

@ -24,33 +24,26 @@ class EditEntryScreen(Screen):
BINDINGS = [ BINDINGS = [
Binding("ctrl+q", "quit", "Quit"), Binding("ctrl+q", "quit", "Quit"),
Binding("ctrl+s", "save", "Save"), Binding("ctrl+s", "save", "Save"),
Binding("shift+f5", "new_entry", "New Entry"), Binding("ctrl+n", "new_entry", "New Entry"),
Binding("f5", "next_entry", "Next Entry"), Binding("ctrl+shift+n", "next_entry", "Next Entry"),
Binding("f4", "prev_entry", "Previous Entry"), Binding("ctrl+shift+p", "prev_entry", "Previous Entry"),
Binding("ctrl+r", "rename_entry", "Rename Entry"), Binding("ctrl+r", "rename_entry", "Rename Entry"),
Binding("f8", "toggle_sidebar", "Toggle Photos"), Binding("f8", "toggle_sidebar", "Toggle Photos"),
Binding("f9", "toggle_focus", "Toggle Focus"), Binding("f9", "toggle_focus", "Toggle Focus"),
Binding("escape", "back_to_list", "Back to List"), Binding("escape", "back_to_list", "Back to List"),
] ]
def __init__(self, diary_id: int = 1,create_new: bool = True): def __init__(self, diary_id: int = 1):
super().__init__() super().__init__()
if create_new:
self.current_entry_index = -1
self.is_new_entry = True
self.next_entry_id = None
else:
self.is_new_entry = False
self.current_entry_index = 0
self.next_entry_id = 1
self.new_entry_title = ""
self.new_entry_content = ""
self.diary_id = diary_id self.diary_id = diary_id
self.diary_name = f"Diary {diary_id}" self.diary_name = f"Diary {diary_id}"
self.current_entry_index = 0
self.entries: List[Entry] = [] self.entries: List[Entry] = []
self.is_new_entry = False
self.has_unsaved_changes = False self.has_unsaved_changes = False
self.new_entry_content = ""
self.new_entry_title = "New Entry"
self.next_entry_id = 1
self._updating_display = False self._updating_display = False
self._original_content = "" self._original_content = ""
self.is_refreshing = False self.is_refreshing = False
@ -913,22 +906,11 @@ class EditEntryScreen(Screen):
self.notify("Empty entry cannot be saved") self.notify("Empty entry cannot be saved")
return return
# Passe a lista de fotos para o método de criação # Passe a lista de fotos para o método de criação
if self.new_entry_title == "": self.call_later(self._async_create_entry, content, photos_to_link)
self.app.push_screen(RenameEntryModal(current_name=""), lambda result: self._handle_save_after_rename(result,content,
photos_to_link))
else:
self.call_later(self._async_create_entry, content, photos_to_link)
else: else:
# Passe a lista de fotos para o método de atualização # Passe a lista de fotos para o método de atualização
self.call_later(self._async_update_entry, content, photos_to_link) self.call_later(self._async_update_entry, content, photos_to_link)
def _handle_save_after_rename(self, result: str | None, content: str, photos_to_link: List[Photo]) -> None:
if result is None:
self.notify("Save cancelled")
return
self.new_entry_title = result
self.call_later(self._async_create_entry, content, photos_to_link)
async def _async_create_entry(self, content: str, photos_to_link: List[Photo]): async def _async_create_entry(self, content: str, photos_to_link: List[Photo]):
"""Creates a new entry and links the referenced photos.""" """Creates a new entry and links the referenced photos."""
try: try:
@ -955,7 +937,7 @@ class EditEntryScreen(Screen):
self.is_new_entry = False self.is_new_entry = False
self.has_unsaved_changes = False self.has_unsaved_changes = False
self._original_content = new_entry.text self._original_content = new_entry.text
self.new_entry_title = "" self.new_entry_title = "New Entry"
self.next_entry_id = max(entry.id for entry in self.entries) + 1 self.next_entry_id = max(entry.id for entry in self.entries) + 1
self._update_entry_display() self._update_entry_display()
@ -1000,60 +982,52 @@ class EditEntryScreen(Screen):
except Exception as e: except Exception as e:
self.notify(f"Error updating entry: {str(e)}") self.notify(f"Error updating entry: {str(e)}")
def check_key(self, event):
"""Check for custom key handling before bindings are processed"""
# Sidebar shortcuts
if self.sidebar_focused and self.sidebar_visible:
sidebar_keys = ["i", "n", "d", "e"]
if event.key in sidebar_keys:
if event.key == "i":
self.action_insert_photo()
elif event.key == "n":
self.action_ingest_new_photo()
elif event.key == "d":
self.action_delete_photo()
elif event.key == "e":
self.action_edit_photo()
return True # Indica que o evento foi processado
# Text area shortcuts
elif self.focused is self.text_entry:
if event.key in ["tab", "shift+tab"]:
if event.key == "shift+tab":
self._handle_shift_tab()
elif event.key == "tab":
self.text_entry.insert('\t')
return True # Indica que o evento foi processado
return False # Não foi processado, continuar com bindings
def _handle_shift_tab(self):
"""Handle shift+tab for removing indentation"""
textarea = self.text_entry
row, col = textarea.cursor_location
lines = textarea.text.splitlines()
if row < len(lines):
line = lines[row]
if line.startswith('\t'):
lines[row] = line[1:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - 1, 0))
elif line.startswith(' '): # 4 spaces
lines[row] = line[4:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - 4, 0))
elif line.startswith(' '):
n = len(line) - len(line.lstrip(' '))
to_remove = min(n, 4)
lines[row] = line[to_remove:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - to_remove, 0))
def on_key(self, event): def on_key(self, event):
if self.check_key(event): # Sidebar contextual shortcuts
if self.sidebar_focused and self.sidebar_visible:
if event.key == "i":
self.action_insert_photo()
event.stop()
elif event.key == "n":
self.action_ingest_new_photo()
event.stop()
elif event.key == "d":
self.action_delete_photo()
event.stop()
elif event.key == "e":
self.action_edit_photo()
event.stop()
# Shift+Tab: remove indent
elif self.focused is self.text_entry and event.key == "shift+tab":
textarea = self.text_entry
row, col = textarea.cursor_location
lines = textarea.text.splitlines()
if row < len(lines):
line = lines[row]
if line.startswith('\t'):
lines[row] = line[1:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - 1, 0))
elif line.startswith(' '): # 4 spaces
lines[row] = line[4:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - 4, 0))
elif line.startswith(' '):
n = len(line) - len(line.lstrip(' '))
to_remove = min(n, 4)
lines[row] = line[to_remove:]
textarea.text = '\n'.join(lines)
textarea.cursor_location = (row, max(col - to_remove, 0))
event.stop()
# Tab: insert tab
elif self.focused is self.text_entry and event.key == "tab":
self.text_entry.insert('\t')
event.stop() event.stop()
return
def on_footer_action(self, event) -> None: def on_footer_action(self, event) -> None:
"""Handle clicks on footer actions (Textual 3.x).""" """Handle clicks on footer actions (Textual 3.x)."""