Git Product home page Git Product logo

cupcake's Issues

Delimiters are unwieldy with autocompletion

Bug

Describe the bug

Right now straight typing through delimiters provides annoying behavior that slows down the ability to fluidly continue writing code, and duplicates the delimiters unnecessarily like seen here:
fixthis

Typically when writing these, the cursor by default should move through the second quotation like the following:
likethis

Exceptions to this rule

There are however a couple of situations you'd want this behavior (as pointed out by @oliverbooth):

If you intentionally move back like so:
ex1

Or when adding quotes around a selection like so:
ex2

Autocomplete shall use tkinter's treeview widget

As for how autocomplete list is currently implemented, it have a lot of optimization problems. When big files are opened, autocomplete seems to be less responsive, leaving the editor not responsive. This can be more optimized by using the tree view widget with some styling

Strange autocomplete

2023-07-18.16-15-39.mp4

First, autocomplete will insert the word, not really complete the word that user input.
Second, when I input "{" it will complete a "]" for some reason.

Scrollbar

Editor currently have no scrollbar, this shall be implemented

Anyone else having issues with autocompletion

Hi

Anyone else getting an issue with autocompletion, this is what I am getting.

issue.mov

I have hacked together a fix and I am now getting this

fix.mov

However maybe it is just an issue on my machine, so just checking if others are experiencing this.

Bracket filling

Bracket filling is an essential feature for code editors, this shall be implemented

More language support

I want more language support but only C++ and Plain text is supported. I also want Python support.

Open discussions

I haven't been able to actually use cupcake yet but I would like to be able to ask questions about it and give feedback through discussions :).

[FEATURE] API

Make a full fledged API for cupcake to be used with other tkinter applications, mainly Biscuit.

Code folding

  • show folding marks (purely based on indentation level increases rn)
class LineNumbers(Canvas):
    def __init__(self, master, text=None, *args, **kwargs):
        super().__init__(master, *args, **kwargs)
        self.config(width=65, bd=0, highlightthickness=0)
        self.text = text
        self.text.bind("<Configure>", self.redraw)

    def get_indentation_level(self, line):
        """Get the indentation level of a given line."""
        return len(line) - len(line.lstrip())

    def redraw(self, *_):
        self.delete(tk.ALL)

        prev_indent = 0
        i = self.text.index("@0,0")
        while True:
            dline = self.text.dlineinfo(i)
            if dline is None:
                break

            y = dline[1]
            linenum = str(i).split(".")[0]

            # Get the text content of the current line
            line_content = self.text.get(f"{linenum}.0", f"{linenum}.end")
            current_indent = self.get_indentation_level(line_content)

            # Determine if the current line has more indentation than the previous line
            if current_indent > prev_indent:
                line_num_with_indent = f"{linenum} +"
            else:
                line_num_with_indent = linenum

            # to highlight the current line
            curline = self.text.dlineinfo(tk.INSERT)
            cur_y = curline[1] if curline else None

            if not cur_y:
                i = self.text.index(f"{i}+1line")
                continue

            self.create_text(40, y, anchor=tk.NE, text=line_num_with_indent, font=("Consolas", 14), tag=i)
            
            # Update the previous indentation level
            prev_indent = current_indent
            i = self.text.index(f"{i}+1line")

image

Custom language support

Hi, its me again.
** 3 Issues in one repo! **
Anyway, I want custom language support for editor
Like

class MyLexer:
      keywords = ["echo", "rmdir", "if"]
e = Editor(root, lexer=MyLexer)
e.pack()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.