├── README.md ├── advanced_notepad.py └── installer.sh /README.md: -------------------------------------------------------------------------------- 1 | Advanced Notepad 2 | 3 | Advanced Notepad is a feature-rich text editor built using Python and Tkinter. It includes functionalities such as file operations, text search and replace, customizable themes, font settings, and more. 4 | Features 5 | 6 | File Operations: Create, open, save, and save files with ease. 7 | Edit Options: Cut, copy, paste, undo, and redo. 8 | Search and Replace: Quickly find and replace text within the document. 9 | Word Count: View the total word count in the document. 10 | Font Customization: Change font family and size. 11 | Themes: Toggle between light mode and dark mode. 12 | Status Bar: Displays the current line and column number. 13 | Keyboard Shortcuts: Includes common shortcuts for better productivity. 14 | 15 | Installation 16 | 17 | You can install Advanced Notepad on your system and make it accessible via the terminal. 18 | Prerequisites 19 | 20 | Python 3.x installed on your system. 21 | Tkinter installed (comes pre-installed with Python on most systems). 22 | 23 | Steps 24 | 25 | Clone the repository or copy the files to your desired directory: 26 | 27 | git clone https://github.com/yourusername/advanced-notepad.git 28 | cd advanced-notepad 29 | 30 | Run the installation script: 31 | 32 | chmod +x install_editor.sh 33 | ./install_editor.sh 34 | 35 | Restart your terminal or run: 36 | 37 | source ~/.bashrc 38 | 39 | Launch the editor by typing: 40 | 41 | advanced_notepad 42 | 43 | Usage 44 | Keyboard Shortcuts 45 | Shortcut Action 46 | Ctrl+N New file 47 | Ctrl+O Open file 48 | Ctrl+S Save file 49 | Ctrl+Z Undo 50 | Ctrl+Y Redo 51 | Ctrl+F Find text 52 | Ctrl+H Replace text 53 | Ctrl+X Cut 54 | Ctrl+C Copy 55 | Ctrl+V Paste 56 | Uninstallation 57 | 58 | To remove the editor, run the following command: 59 | 60 | make uninstall 61 | 62 | or, if installed manually: 63 | 64 | rm -f ~/.local/bin/advanced_notepad 65 | 66 | Screenshots 67 | 68 | Editor in Light Mode 69 | 70 | Editor in Dark Mode 71 | Contributing 72 | 73 | Feel free to submit issues or pull requests for improvements. Contributions are always welcome! 74 | 75 | -------------------------------------------------------------------------------- /advanced_notepad.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import filedialog as fd 3 | from tkinter import messagebox, simpledialog, font 4 | import os 5 | 6 | # Initialize root 7 | root = Tk() 8 | root.title("Untitled - Advanced Notepad") 9 | root.geometry("800x600") 10 | 11 | # Global Variables 12 | current_file = None 13 | 14 | # Functions 15 | def new_file(): 16 | global current_file 17 | current_file = None 18 | text_area.delete(1.0, END) 19 | root.title("Untitled - Advanced Notepad") 20 | 21 | def open_file(): 22 | global current_file 23 | file_path = fd.askopenfilename(filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")]) 24 | if file_path: 25 | current_file = file_path 26 | root.title(os.path.basename(file_path)) 27 | with open(file_path, "r") as file: 28 | text_area.delete(1.0, END) 29 | text_area.insert(1.0, file.read()) 30 | 31 | def save_file(): 32 | global current_file 33 | if not current_file: 34 | save_as_file() 35 | else: 36 | with open(current_file, "w") as file: 37 | file.write(text_area.get(1.0, END)) 38 | messagebox.showinfo("Save", "File saved successfully!") 39 | 40 | def save_as_file(): 41 | global current_file 42 | file_path = fd.asksaveasfilename(defaultextension=".txt", 43 | filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")]) 44 | if file_path: 45 | current_file = file_path 46 | root.title(os.path.basename(file_path)) 47 | with open(file_path, "w") as file: 48 | file.write(text_area.get(1.0, END)) 49 | messagebox.showinfo("Save As", "File saved successfully!") 50 | 51 | def cut_text(): 52 | text_area.event_generate("<>") 53 | 54 | def copy_text(): 55 | text_area.event_generate("<>") 56 | 57 | def paste_text(): 58 | text_area.event_generate("<>") 59 | 60 | def undo_action(): 61 | text_area.event_generate("<>") 62 | 63 | def redo_action(): 64 | text_area.event_generate("<>") 65 | 66 | def search_text(): 67 | find_word = simpledialog.askstring("Find", "Enter text to find:") 68 | if find_word: 69 | start_idx = text_area.search(find_word, "1.0", END) 70 | if start_idx: 71 | end_idx = f"{start_idx}+{len(find_word)}c" 72 | text_area.tag_add("highlight", start_idx, end_idx) 73 | text_area.tag_config("highlight", background="yellow", foreground="black") 74 | text_area.see(start_idx) 75 | else: 76 | messagebox.showinfo("Find", f"'{find_word}' not found.") 77 | 78 | def replace_text(): 79 | find_word = simpledialog.askstring("Find", "Enter text to find:") 80 | replace_word = simpledialog.askstring("Replace", "Enter replacement text:") 81 | if find_word and replace_word: 82 | content = text_area.get(1.0, END) 83 | new_content = content.replace(find_word, replace_word) 84 | text_area.delete(1.0, END) 85 | text_area.insert(1.0, new_content) 86 | 87 | def word_count(): 88 | content = text_area.get(1.0, END) 89 | words = len(content.split()) 90 | messagebox.showinfo("Word Count", f"Total words: {words}") 91 | 92 | def change_font(): 93 | font_family = simpledialog.askstring("Font", "Enter font family (e.g., Arial):") 94 | font_size = simpledialog.askinteger("Font Size", "Enter font size:") 95 | if font_family and font_size: 96 | new_font = font.Font(family=font_family, size=font_size) 97 | text_area.config(font=new_font) 98 | 99 | def toggle_theme(): 100 | current_bg = text_area.cget("background") 101 | if current_bg == "white": 102 | text_area.config(background="black", foreground="white", insertbackground="white") 103 | else: 104 | text_area.config(background="white", foreground="black", insertbackground="black") 105 | 106 | # Menubar setup 107 | menubar = Menu(root) 108 | 109 | # File Menu 110 | filemenu = Menu(menubar, tearoff=0) 111 | filemenu.add_command(label="New", command=new_file, accelerator="Ctrl+N") 112 | filemenu.add_command(label="Open", command=open_file, accelerator="Ctrl+O") 113 | filemenu.add_command(label="Save", command=save_file, accelerator="Ctrl+S") 114 | filemenu.add_command(label="Save As", command=save_as_file) 115 | filemenu.add_separator() 116 | filemenu.add_command(label="Exit", command=root.quit) 117 | menubar.add_cascade(label="File", menu=filemenu) 118 | 119 | # Edit Menu 120 | editmenu = Menu(menubar, tearoff=0) 121 | editmenu.add_command(label="Undo", command=undo_action, accelerator="Ctrl+Z") 122 | editmenu.add_command(label="Redo", command=redo_action, accelerator="Ctrl+Y") 123 | editmenu.add_separator() 124 | editmenu.add_command(label="Cut", command=cut_text, accelerator="Ctrl+X") 125 | editmenu.add_command(label="Copy", command=copy_text, accelerator="Ctrl+C") 126 | editmenu.add_command(label="Paste", command=paste_text, accelerator="Ctrl+V") 127 | editmenu.add_separator() 128 | editmenu.add_command(label="Find", command=search_text, accelerator="Ctrl+F") 129 | editmenu.add_command(label="Replace", command=replace_text, accelerator="Ctrl+H") 130 | editmenu.add_command(label="Word Count", command=word_count) 131 | menubar.add_cascade(label="Edit", menu=editmenu) 132 | 133 | # Format Menu 134 | formatmenu = Menu(menubar, tearoff=0) 135 | formatmenu.add_command(label="Change Font", command=change_font) 136 | menubar.add_cascade(label="Format", menu=formatmenu) 137 | 138 | # View Menu 139 | viewmenu = Menu(menubar, tearoff=0) 140 | viewmenu.add_command(label="Toggle Theme", command=toggle_theme) 141 | menubar.add_cascade(label="View", menu=viewmenu) 142 | 143 | # Status Bar 144 | status_bar = Label(root, text="Line 1, Column 1", anchor=E) 145 | status_bar.pack(side=BOTTOM, fill=X) 146 | 147 | def update_status(event=None): 148 | row, col = text_area.index(INSERT).split(".") 149 | status_bar.config(text=f"Line {row}, Column {col}") 150 | 151 | # Text Area 152 | text_area = Text(root, wrap="word", undo=True) 153 | text_area.pack(expand=True, fill=BOTH) 154 | text_area.bind("", update_status) 155 | 156 | # Configure Menubar 157 | root.config(menu=menubar) 158 | 159 | # Shortcuts 160 | root.bind("", lambda event: new_file()) 161 | root.bind("", lambda event: open_file()) 162 | root.bind("", lambda event: save_file()) 163 | root.bind("", lambda event: search_text()) 164 | root.bind("", lambda event: replace_text()) 165 | root.bind("", lambda event: undo_action()) 166 | root.bind("", lambda event: redo_action()) 167 | 168 | root.mainloop() 169 | 170 | -------------------------------------------------------------------------------- /installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Define variables 4 | INSTALL_DIR="$HOME/.local/bin" 5 | SCRIPT_NAME="advanced_notepad" 6 | PYTHON_SCRIPT="advanced_notepad.py" 7 | 8 | # Ensure the installation directory exists 9 | mkdir -p "$INSTALL_DIR" 10 | 11 | # Copy the Python script to the installation directory 12 | cp "$PYTHON_SCRIPT" "$INSTALL_DIR/$SCRIPT_NAME" 13 | 14 | # Make the script executable 15 | chmod +x "$INSTALL_DIR/$SCRIPT_NAME" 16 | 17 | # Add the installation directory to PATH if not already present 18 | if ! echo "$PATH" | grep -q "$HOME/.local/bin"; then 19 | echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.zshrc" 20 | echo 'PATH updated. Please restart your terminal or run `source ~/.zshrc`.' 21 | fi 22 | 23 | echo "Installation complete! Run '$SCRIPT_NAME' to start the editor." 24 | 25 | --------------------------------------------------------------------------------