Skip to content

Commit a274c91

Browse files
lmao massive rework
1 parent db07f87 commit a274c91

33 files changed

+1394
-317
lines changed

build_linux.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# filepath: build_linux.sh
3+
4+
echo "==========================================="
5+
echo "File Structure Viewer - Linux Builder"
6+
echo "==========================================="
7+
echo
8+
9+
# Check if Python is installed
10+
if ! command -v python3 &> /dev/null; then
11+
echo "❌ Python 3 is not installed. Please install Python 3 first."
12+
exit 1
13+
fi
14+
15+
echo "Installing dependencies..."
16+
pip3 install pyperclip cx_Freeze
17+
18+
echo "Building Linux binary..."
19+
python3 setup.py build
20+
21+
echo "✅ Linux build complete!"
22+
echo "Binary location: build/exe.linux-x86_64-*/FileStructureViewer_v3_Linux"
23+
24+
# Make the built file executable
25+
find build -name "FileStructureViewer_v3_Linux" -exec chmod +x {} \;
26+
27+
echo "✅ Binary is now executable!"

controllers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Controllers package
192 Bytes
Binary file not shown.
5.25 KB
Binary file not shown.

controllers/main_controller.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
"""
2+
Main application controller
3+
"""
4+
import os
5+
import pyperclip
6+
from models.file_manager import FileManager
7+
from views.main_window import MainWindow
8+
from utils.theme import ModernTheme
9+
from utils.constants import STATUS_READY, STATUS_LOADING, STATUS_REFRESHING, STATUS_COPYING
10+
11+
class MainController:
12+
def __init__(self, root):
13+
self.root = root
14+
self.file_manager = FileManager()
15+
self.theme = ModernTheme()
16+
17+
# Create main window
18+
self.view = MainWindow(root, self)
19+
20+
# Initialize state
21+
self.current_folder = None
22+
self.current_ignore_folders = []
23+
24+
def load_folder(self, folder_path):
25+
"""Load and display folder structure"""
26+
if not os.path.exists(folder_path):
27+
self.update_status("❌ Invalid folder path", self.theme.TEXT_ERROR)
28+
return
29+
30+
self.update_status(STATUS_LOADING, self.theme.TEXT_ACCENT)
31+
self.root.update_idletasks()
32+
33+
try:
34+
self.current_folder = folder_path
35+
self.current_ignore_folders = self.view.get_header_panel().get_ignore_folders()
36+
37+
# Update all panels
38+
self.view.get_tree_panel().populate_tree(folder_path, self.current_ignore_folders)
39+
self.view.get_buttons_panel().populate_buttons(folder_path, self.current_ignore_folders)
40+
self.view.get_ascii_panel().display_ascii_tree(folder_path, self.current_ignore_folders)
41+
42+
# Get folder stats for progress
43+
stats = self.file_manager.get_folder_stats(folder_path, self.current_ignore_folders)
44+
self.view.update_progress(f"{stats['total_files']} files, {stats['total_lines']:,} lines")
45+
46+
self.update_status("✅ Folder loaded successfully!", self.theme.TEXT_SUCCESS)
47+
self.root.after(3000, lambda: self.update_status(STATUS_READY))
48+
49+
except Exception as e:
50+
self.update_status(f"❌ Error loading folder: {str(e)}", self.theme.TEXT_ERROR)
51+
52+
def refresh_display(self):
53+
"""Refresh the current display"""
54+
if not self.current_folder:
55+
self.update_status("❌ No folder selected", self.theme.TEXT_ERROR)
56+
return
57+
58+
self.update_status(STATUS_REFRESHING, self.theme.TEXT_ACCENT)
59+
self.load_folder(self.current_folder)
60+
61+
def copy_single_file(self, file_path):
62+
"""Copy content of a single file to clipboard"""
63+
try:
64+
file_name = os.path.basename(file_path)
65+
content = self.file_manager.get_file_content(file_path)
66+
lines = self.file_manager.count_lines_of_code(file_path)
67+
68+
# Format content with header
69+
formatted_content = f"// File: {file_name} ({lines} lines)\n"
70+
formatted_content += f"// Path: {file_path}\n"
71+
formatted_content += "// " + "="*78 + "\n\n"
72+
formatted_content += content
73+
74+
pyperclip.copy(formatted_content)
75+
self.update_status(f"✅ {file_name} copied to clipboard!", self.theme.TEXT_SUCCESS)
76+
self.root.after(3000, lambda: self.update_status(STATUS_READY))
77+
78+
except Exception as e:
79+
self.update_status(f"❌ Error copying file: {str(e)}", self.theme.TEXT_ERROR)
80+
81+
def copy_all_files(self):
82+
"""Copy all files content to clipboard"""
83+
if not self.current_folder:
84+
self.update_status("❌ No folder selected", self.theme.TEXT_ERROR)
85+
return
86+
87+
self.update_status(STATUS_COPYING, self.theme.TEXT_ACCENT)
88+
self.root.update_idletasks()
89+
90+
try:
91+
content, file_count = self.file_manager.get_all_files_content(
92+
self.current_folder, self.current_ignore_folders
93+
)
94+
95+
if content:
96+
pyperclip.copy(content)
97+
self.update_status(f"✅ {file_count} files copied to clipboard!", self.theme.TEXT_SUCCESS)
98+
else:
99+
self.update_status("❌ No files to copy", self.theme.TEXT_ERROR)
100+
101+
self.root.after(3000, lambda: self.update_status(STATUS_READY))
102+
103+
except Exception as e:
104+
self.update_status(f"❌ Error copying files: {str(e)}", self.theme.TEXT_ERROR)
105+
106+
def copy_ascii_tree(self):
107+
"""Copy ASCII tree to clipboard"""
108+
try:
109+
content = self.view.get_ascii_panel().get_content()
110+
if content.strip():
111+
pyperclip.copy(content)
112+
self.update_status("✅ ASCII tree copied to clipboard!", self.theme.TEXT_SUCCESS)
113+
self.root.after(3000, lambda: self.update_status(STATUS_READY))
114+
else:
115+
self.update_status("❌ No tree to copy", self.theme.TEXT_ERROR)
116+
except Exception as e:
117+
self.update_status(f"❌ Error copying tree: {str(e)}", self.theme.TEXT_ERROR)
118+
119+
def show_statistics(self):
120+
"""Show folder statistics"""
121+
if not self.current_folder:
122+
self.update_status("❌ No folder selected", self.theme.TEXT_ERROR)
123+
return
124+
125+
try:
126+
stats = self.file_manager.get_folder_stats(self.current_folder, self.current_ignore_folders)
127+
self.view.show_statistics_dialog(stats)
128+
except Exception as e:
129+
self.update_status(f"❌ Error generating statistics: {str(e)}", self.theme.TEXT_ERROR)
130+
131+
def update_status(self, message, color=None):
132+
"""Update status bar"""
133+
self.view.update_status(message, color)

0 commit comments

Comments
 (0)