Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _cmd_proxy() #23

Merged
merged 19 commits into from
Apr 17, 2023
Merged

Fix _cmd_proxy() #23

merged 19 commits into from
Apr 17, 2023

Conversation

Moosems
Copy link
Collaborator

@Moosems Moosems commented Apr 10, 2023

@rdbende This isn't quite working. Could you work on this while I eat dinner?

@rdbende
Copy link
Owner

rdbende commented Apr 10, 2023

Tomorrow

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 10, 2023

I figured out what's wrong. It's inserting the text first and then I'm trying to figure out where in the heck the inserted text is.

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 10, 2023

I think I got it working. We should do some extensive tests to find any possible issue that could occur from this as its a pretty big change. If it works properly then this fixes #21.

@Moosems Moosems changed the title Start fix Start insert() fix Apr 11, 2023
@Moosems Moosems added the bug Something isn't working label Apr 11, 2023
@Moosems Moosems self-assigned this Apr 11, 2023
@rdbende
Copy link
Owner

rdbende commented Apr 11, 2023

@Moosems Please find those "most outlandish issues". I haven't tested this with .replace for example, but I guess it will break.

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

Delete breaks (started working on a fix) but I haven't yet dove into replace a bunch.

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

@rdbende I don't know what in the world was changed but inserting is now broken. The insert part was actually pretty good so I would've stuck with that.

Code that breaks it:

from chlorophyll import CodeView
from tkinter import Tk

root = Tk()
cd = CodeView(root)
cd.pack()
cd.insert("end", "\"\"\"This is a test\n")
root.mainloop()
from chlorophyll import CodeView
from tkinter import Tk

root = Tk()
cd = CodeView(root)
cd.pack()
cd.replace("1.0", "end", "print('Hello, World!')")
root.mainloop()

@rdbende
Copy link
Owner

rdbende commented Apr 11, 2023

@Moosems I simplified the code, because there was some unnecessary hacking-around with indexes, and the delete was completely broken. Now it mostly works. Feel free to add more changes, I won't be able to work on this today.

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

Test (works):

from chlorophyll import CodeView
from tkinter import Tk

root = Tk()
cd = CodeView(root)
cd.pack()
cd.insert("end", "\"\"\"\nThis is a test\n\n\n\n\"\"\"")
cd.insert("end", "\n\nprint()")
root.mainloop()

@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

Typing doesn't highlight until you go to a new line (press return)

chlorophyll/codeview.py Outdated Show resolved Hide resolved
@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

highlight_area() highlights everything one char to the left:
Screen Shot 2023-04-11 at 8 25 32 AM

@Moosems Moosems changed the title Start insert() fix Fix _cmd_proxy() Apr 11, 2023
chlorophyll/codeview.py Outdated Show resolved Hide resolved
@Moosems
Copy link
Collaborator Author

Moosems commented Apr 11, 2023

Traceback (most recent call last):
  File "/Users/Moosems/Desktop/chlorophyll/test.py", line 283, in <module>
    root.mainloop()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 1485, in mainloop
    self.tk.mainloop(n)
  File "/Users/Moosems/Desktop/chlorophyll/chlorophyll/codeview.py", line 109, in _cmd_proxy
    str(self.tk.call(self._orig, "index", args[0])).split(".")[0]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: text doesn't contain any characters tagged with "sel"

@Moosems Moosems linked an issue Apr 11, 2023 that may be closed by this pull request
Moosems and others added 3 commits April 13, 2023 15:11
@Moosems Moosems requested a review from rdbende April 16, 2023 19:30
@Moosems
Copy link
Collaborator Author

Moosems commented Apr 16, 2023

Looks good to me.

@rdbende rdbende merged commit 6a8e1d7 into main Apr 17, 2023
@Moosems Moosems deleted the start_insert_fix branch April 21, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inserted strings don't get highlighted
2 participants