diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..f0bb786 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,3 @@ +"""Code Editor package.""" + +__version__ = "0.1.0" diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..a2535a1 --- /dev/null +++ b/src/main.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Main module for the codeeditor application.""" + +import logging +import os +import sys +from pathlib import Path + +import streamlit as st + +from codeeditor.chat_manager import ChatManager +from codeeditor.execution_engine import ExecutionEngine +from codeeditor.file_manager import FileManager +from codeeditor.search_manager import SearchManager +from codeeditor.ui_components import setup_ui + +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + handlers=[logging.StreamHandler(sys.stdout)], +) + +logger = logging.getLogger(__name__) + + +def main(): + """Execute the main entry point for the application.""" + # Initialize session state for storing app state + if "file_manager" not in st.session_state: + # Start with an empty directory by default + empty_dir = "" + st.session_state.file_manager = FileManager( + Path(empty_dir) if empty_dir else Path.cwd() + ) + + if "workspace_path" not in st.session_state: + st.session_state.workspace_path = "" + + if "chat_manager" not in st.session_state: + st.session_state.chat_manager = ChatManager() + + if "execution_engine" not in st.session_state: + st.session_state.execution_engine = ExecutionEngine() + + if "search_manager" not in st.session_state: + st.session_state.search_manager = SearchManager() + + if "current_file" not in st.session_state: + st.session_state.current_file = None + + if "expanded_folders" not in st.session_state: + st.session_state.expanded_folders = set() + + # Initialize UI dialog state variables + if "show_new_file_dialog" not in st.session_state: + st.session_state.show_new_file_dialog = False + + if "show_new_folder_dialog" not in st.session_state: + st.session_state.show_new_folder_dialog = False + + # Initialize file filter + if "file_filter" not in st.session_state: + st.session_state.file_filter = "All Files" + + # Initialize recent projects (for future use) + if "recent_projects" not in st.session_state: + st.session_state.recent_projects = [] + + # Initialize chat input clear flag + if "clear_chat_input" not in st.session_state: + st.session_state.clear_chat_input = False + + # Ensure chat_history is synchronized with chat_manager + st.session_state.chat_history = st.session_state.chat_manager.get_history() + + # Setup the UI components + setup_ui() + + +if __name__ == "__main__": + main() diff --git a/src/streamlit_app.py b/src/streamlit_app.py new file mode 100644 index 0000000..bf810e2 --- /dev/null +++ b/src/streamlit_app.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Streamlit entry point for the codeeditor application.""" + +import os +import sys +from pathlib import Path + +# Add the src directory to the Python path +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) + +# Import the main function from main.py +from main import main + +if __name__ == "__main__": + main()