Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions GPL-3.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) [2024] [Ramsyan Tungga Kiansantang][LcfherShell]
Copyright (C) [2024] Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

===

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://www.fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for software
and other kinds of works. The licenses for most software and other
practical works are designed to take away your freedom to share and
change the works. By contrast, our General Public Licenses are intended
to guarantee your freedom to share and change all versions of a program
to make sure it remains free software for all its users.

When we speak of free software, we are referring to freedom, not price.
Our General Public Licenses are designed to make sure that you have the
freedom to distribute copies of free software (and charge for this service
if you wish), that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free programs,
and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone
to deny you these rights or to ask you to surrender the rights. These
restrictions translate to certain responsibilities for you if you distribute
copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis
or for a fee, you must pass on the same freedoms to the recipients that you
received. You must make sure that they, too, receive or can get the source
code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.

Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its
recipients to know that what they have is not the original, so that any
problems introduced by others will not reflect on the original authors'
reputations.

Finally, any free program is threatened constantly by software patents.
We wish to avoid the danger that redistributors of a free program will
individually obtain patent licenses, in effect making the program
proprietary. To prevent this, we have made it clear that any patent must
be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

TERMS AND CONDITIONS

0. Definitions.

"This License" refers to version 3 of the GNU General Public License.

"Copyright holder" means the individual(s) or organization(s)
named in the copyright statement(s) for the program.

"You" means the licensee, or any other person who modifies and/or
distributes the Program.

"Program" means the work licensed under this License.

"Modified version" means the Program with changes made to it.

"Source code" means the preferred form of the Program for making
modifications to it.

"Object code" means any non-source form of a work.

"Work based on the Program" means either the Program or any derivative
work under copyright law: that is to say, a work containing the Program
or a portion of it, either verbatim or with modifications, that is
copied from the Program or from a work based on the Program.

"Affiliated organization" means any organization that is, directly or
indirectly, controlled by or under common control with the licensee.

1. Source Code.

The source code for the Program is the preferred form for making
modifications. The source code must be distributed as part of the Program.

2. Copyleft.

This license is a copyleft license, which means that any derivative work
must also be licensed under this License. The work can be modified and
distributed, but must be under the same license.

3. Distribution of Modified Code.

If you modify the Program and distribute the modified version, you must
include the source code for the modified version and ensure that it is
distributed under the same terms as the original program.

4. License.

This License is designed to ensure that the Program remains free. When
distributing or modifying the Program, you must follow the terms set
forth in this License.

5. No Warranty.

There is no warranty for the Program. It is provided "as is" without
any express or implied warranties.

6. Termination.

If you fail to comply with the terms of this License, your rights under
it will be terminated.

7. Additional Terms.

You may not impose additional restrictions on the rights granted by this
License.

8. Acceptance.

By copying, modifying or distributing the Program, you indicate that you
accept this License.

9. Miscellaneous.

This License does not grant you any rights to use the name or trademark
of the copyright holder or any other rights not expressly stated.

END OF TERMS AND CONDITIONS
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# SuperNano
Ini adalah Aplikasi Text-Editor berbasis TUI
<img src="https://repository-images.githubusercontent.com/847198464/b36c0223-b3fa-4846-8f82-21e1b48d7021" alt="Banner" style="max-width: 100%; height: auto;" />

Here is the documentation for the `SuperNano` script, a console-based editor written in Python with the `py_cui` module. It provides an interface for managing files and directories and provides basic text editing features.

---

# SuperNano Documentation

## Description
`SuperNano` is a console-based text editor that allows users to open, edit, save and delete files directly from a text-based interface. It also provides file editing, directory navigation and file search features.

### Key Features:
- **Directory Navigation**: Displays the contents of directories and allows navigation between directories.
- **Text Editing**: Allows editing of text files with undo feature.
- **File Saving**: Saves changes to the opened file.
- **File Deletion**: Deletes the selected file.
- **File Search**: Searches for files or directories by name.

## Code Structure
This script is divided into several important parts:
1. **Imports**: This section imports the modules required to run the application. In addition to the standard Python modules, this script also imports some specialized modules that serve for system management, file management, error handling, and timing.

2. **Configure Logging**: Set up logging to record events or errors that occur during application running.

3. **SetTitle function**: This function is used to set the title of the console window according to the path of the current file or directory.

4. **SuperNano class**: This class is the core of the application that manages various features such as opening files, saving files, deleting files, directory navigation, and others.

5. **Function `parse_args`**: This function is used to parse command line arguments that specify the target file or directory to edit.

6. **The `main` function**: The main function that initializes the `PyCUI` object, sets the application title, and starts the user interface.

7. **Safe Execution**: Uses `SafeProcessExecutor` to safely run the application using threads.

## Implementation Details

### Class `SuperNano`
This class handles all the functionality of the application and is initialized with the parameters `root` (`PyCUI` object) and `path` (file or directory path). Some important methods in this class are:

- **`__init__`**: Initializes the interface and determines if `path` is a file or directory.
- **`open_new_directory`**: Opens and displays the contents of the new directory.
- **`open_file_dir`**: Opens a file or navigates to the selected directory.
- **`save_opened_file`**: Saves the currently opened file.
- **`delete_selected_file`**: Deletes the selected file.
- **`search_files`**: Searches for files in the directory based on the search input.

### `setTitle` function
This function sets the title of the console window to the name of the current file or directory, and adjusts its length to not exceed a certain character limit.

### `parse_args` function
This function is used to process the arguments given through the command line. The arguments will determine which file or directory will be opened by `SuperNano`.

### Safe Execution
The use of `SafeProcessExecutor` ensures that the application runs safely and efficiently, especially when executing functions that may take time.

## How to run script
Run this script through the command line by giving an argument in the form of the path of the file or directory you want to edit. Example:
```
python supernano.py /path/to/directory_or_file
```
or visit [main](https://github.com/LcfherShell/SuperNano/tree/main)

## License
This application was created by Ramsyan Tungga Kiansantang and is licensed under the [GPL v3 License](https://github.com/LcfherShell/SuperNano/blob/V1.0.0/GPL-3.0.txt). For contributions or bug reporting, please visit the provided Github repository.

## Version
- **Version**: V1.0.0
- **Release Date**: July 18, 2024

---

## Conclusion
`SuperNano` is a console-based text editor designed to make it easy to manage files and directories directly from the command line. It offers lightweight tools for users working in a text-based environment.

If you have any questions or need further assistance with the implementation, feel free to contact the developer or check out any additional documentation that may be available. [Email Support](mailto:alfiandecker2@gmail.com,ramstungga2@gmail.com)
12 changes: 12 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os, sys
if getattr(sys, 'frozen', False):
# Jika aplikasi telah dibundel sebagai .exe
__file__ = str(sys.executable)


encoded_dataOLD= "CiAgICB3ZWppX2liaWd5eHN2ID0gV2VqaVR2c2dpd3dJYmlneXhzdihxZWJfYXN2b2l2dz0yKQogICAgIyBHc3BwaWd4IGV2a3lxaXJ4IG1yanN2cWV4bXNyCiAgICB3ZWppX2liaWd5eHN2Lnd5ZnFteChxZW1yKQogICAgeG1xaS53cGlpdCh4bXFpc3l4X3oyKCkpCiAgICB3ZWppX2liaWd5eHN2LndseXhoc2FyKGFlbXg9WHZ5aSk=="
encoded_dataNOW= "CiAgICBxZW1yKCkKICAgIHhtcWkud3BpaXQoeG1xaXN5eF96MigpKQo=="

script_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
all_system_paths = ["/".join(script_dir.split("/")[:-1]), script_dir]
sys.path.extend(all_system_paths)
8 changes: 8 additions & 0 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os, sys
if getattr(sys, 'frozen', False):
# Jika aplikasi telah dibundel sebagai .exe
__file__ = str(sys.executable)

script_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
all_system_paths = ["/".join(script_dir.split("/")[:-1]), script_dir]
sys.path.extend(all_system_paths)
55 changes: 55 additions & 0 deletions libs/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,61 @@ def is_binary_file(file_path):
except Exception as e:
return False

def is_binary_file(file_path):
"""
Menentukan apakah file adalah file biner atau bukan.

Args:
file_path (str): Path ke file yang akan diperiksa.

Returns:
bool: True jika file adalah file biner, False jika bukan.
"""
try:
with open(file_path, "rb+") as file:
chunk = file.read(1024) # Membaca bagian pertama file (1KB)
# Cek apakah file memiliki karakter yang tidak biasa untuk teks
if b"\0" in chunk: # Null byte adalah indikator umum dari file biner
return True
# Cek apakah file sebagian besar berisi karakter teks (misalnya ASCII)
text_chars = b"".join([bytes((i,)) for i in range(32, 127)]) + b"\n\r\t\b"
non_text_chars = chunk.translate(None, text_chars)
if (
len(non_text_chars) / len(chunk) > 0.30
): # Jika lebih dari 30% karakter non-teks
return True
return False
except Exception as e:
return False


def is_binary_file(file_path):
"""
Menentukan apakah file adalah file biner atau bukan.

Args:
file_path (str): Path ke file yang akan diperiksa.

Returns:
bool: True jika file adalah file biner, False jika bukan.
"""
try:
with open(file_path, "rb+") as file:
chunk = file.read(1024) # Membaca bagian pertama file (1KB)
# Cek apakah file memiliki karakter yang tidak biasa untuk teks
if b"\0" in chunk: # Null byte adalah indikator umum dari file biner
return True
# Cek apakah file sebagian besar berisi karakter teks (misalnya ASCII)
text_chars = b"".join([bytes((i,)) for i in range(32, 127)]) + b"\n\r\t\b"
non_text_chars = chunk.translate(None, text_chars)
if (
len(non_text_chars) / len(chunk) > 0.30
): # Jika lebih dari 30% karakter non-teks
return True
return False
except Exception as e:
return False


def check_class_in_package(package_name, class_name):
try:
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
windows-curses==2.3.3
py-cui==0.1.4
pyperclip
psutil
logging
httpx
Loading