Skip to content

Commit

Permalink
Cursor position changes after inserting a suggestion
Browse files Browse the repository at this point in the history
A space character is now inserted after positioning the cursor. This brings the cursor position "out in the open", so now it's faster to keep typing another tag.

+ Some minor code formatting changes to help organize things.
  • Loading branch information
Nenotriple authored Nov 27, 2023
1 parent f7d9ba1 commit 3b650fa
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions img-txt_viewer.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,9 @@ class ImgTxtViewer:
def __init__(self, master):
self.master = master

# Used to create a new ID separate from Python to properly set the app icon.
myappid = 'ImgTxtViewer.Nenotriple'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

# Window settings
master.minsize(965, 300) # Width x Height
master.geometry("1290x645")
self.set_appid()
self.set_window_size(master)
self.set_icon()

# Variables
Expand Down Expand Up @@ -715,6 +711,7 @@ class ImgTxtViewer:
else:
offset = len(selected_suggestion) + 1
self.text_box.mark_set("insert", "{}+{}c".format(start_of_current_word, offset))
self.text_box.insert("insert", " ")

def insert_newline_listmode(self, event=None, called_from_insert=False):
if self.list_mode.get():
Expand Down Expand Up @@ -1458,20 +1455,28 @@ class ImgTxtViewer:
if messagebox.askokcancel("Warning", "This will move the img-txt pair to a local trash folder.\n\nThe trash folder will be created in the selected directory."):
trash_dir = os.path.join(os.path.dirname(self.image_files[self.current_index]), "Trash")
os.makedirs(trash_dir, exist_ok=True)
os.rename(self.image_files[self.current_index], os.path.join(trash_dir, os.path.basename(self.image_files[self.current_index])))
os.rename(self.text_files[self.current_index], os.path.join(trash_dir, os.path.basename(self.text_files[self.current_index])))
del self.image_files[self.current_index]
del self.text_files[self.current_index]
for file_list in [self.image_files, self.text_files]:
os.rename(file_list[self.current_index], os.path.join(trash_dir, os.path.basename(file_list[self.current_index])))
del file_list[self.current_index]
self.total_images_label.config(text=f"/{len(self.image_files)}")
self.show_pair()


#endregion
################################################################################################################################################
################################################################################################################################################
# #
#region - Framework #
# #

def set_appid(self):
myappid = 'ImgTxtViewer.Nenotriple'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

def set_window_size(self, master):
master.minsize(965, 300) # Width x Height
master.geometry("1290x645")

root = Tk()
app = ImgTxtViewer(root)
app.toggle_always_on_top()
Expand Down Expand Up @@ -1507,6 +1512,7 @@ root.mainloop()
- Fix autosave for first and last index navigation.
- List mode: The cursor is now placed at the end of the text file on a newline when navigating between pairs.
- App icon now displays properly in the taskbar.
- Further improvements to cursor positioning after inserting a suggestion.
'''

Expand Down

0 comments on commit 3b650fa

Please sign in to comment.