Skip to content

Commit

Permalink
chore: Move games to extension centre
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Feb 2, 2024
1 parent dc9b6b0 commit 5c93192
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 582 deletions.
6 changes: 3 additions & 3 deletions biscuit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
__version__ = '2.61.0'
__version_info__ = tuple([ int(num) for num in __version__.split('.')])
__version__ = "2.61.3"
__version_info__ = tuple([int(num) for num in __version__.split(".")])

# For tests to run successfully
import sys
from os.path import abspath, dirname, join

sys.path.append(abspath(join(dirname(__file__), '.')))
sys.path.append(abspath(join(dirname(__file__), ".")))


from .core import *
23 changes: 12 additions & 11 deletions biscuit/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ class App(EventManager, GUIManager, ConfigManager):
Manages App Configuration, GUI (Tkinter), Events of the App.
Single point of access to all the important parts of the app. Holds reference to all the components
Single point of access to all the important parts of the app. Holds reference to all the components
of Biscuit and every class of biscuit have a reference back to this `base` class.
i.e. `self.base` is the reference to this class from any other class of biscuit.
Usage
-----
Example: In order to access the open editor from the git:
class Git:
def foo(self):
editor = self.base.editorsmanager.active_editor
editor = self.base.editorsmanager.active_editor
if editor.content and editor.content.exists:
print(editor.path)
Example: Accessing the active editor instance from Foo class of biscuit:
Example: Accessing the active editor instance from Foo class of biscuit:
class Foo:
def foo(self):
editor = self.base.editorsmanager.active_editor
editor = self.base.editorsmanager.active_editor
if (editor.content and editor.content.exists):
print(editor.path)
if (editor.content.editable):
self.base.notifications.info(":)")
"""

def __init__(self, appdir: str="", dir: str="", *args, **kwargs) -> None:
def __init__(self, appdir: str = "", dir: str = "", *args, **kwargs) -> None:
"""
Parameters
----------
Expand All @@ -45,14 +45,14 @@ def __init__(self, appdir: str="", dir: str="", *args, **kwargs) -> None:
dir
optional argument to open a folder from cli
"""

super().__init__(*args, **kwargs)
self.base = self
self.appdir = appdir

self.setup()
self.late_setup()
self.initialize_editor(dir)
self.initialize_editor(dir)

def run(self) -> None:
self.mainloop()
Expand All @@ -69,9 +69,10 @@ def initialize_editor(self, dir: str) -> None:
self.initialized = True

self.palette.generate_help_actionset()
self.logger.info('Initializing editor finished.')
self.logger.info("Initializing editor finished.")

self.update_idletasks()
self.menubar.update()
self.set_title()
self.open_directory(dir)

3 changes: 3 additions & 0 deletions biscuit/core/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import typing

from biscuit.core.api.editors import Editors

if typing.TYPE_CHECKING:
from biscuit.core import App

Expand Down Expand Up @@ -30,6 +32,7 @@ def __init__(self, base: App) -> None:

self.commands = Commands(self.base)
self.logger = Logger(self.base)
self.editors = Editors(self.base)
self.notifications = Notifications(self.base)
self.utils = Utils(self.base)
self.views = Views(self.base)
Expand Down
25 changes: 16 additions & 9 deletions biscuit/core/api/editors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from biscuit.core.components.editors import (DiffEditor, Editor, ImageViewer,
MDEditor, TextEditor)
from biscuit.core.components.views import PanelView, SidebarView

from .endpoint import Endpoint
Expand All @@ -6,33 +8,38 @@
class Editors(Endpoint):
def __init__(self, *a) -> None:
super().__init__(*a)
self.__editors = self._Endpoint__base.editorsmanager
self.editors = self.base.editorsmanager

self.PanelView = PanelView
self.SidebarView = SidebarView
self.TextEditor = TextEditor
self.MDEditor = MDEditor
self.DiffEditor = DiffEditor
self.ImageViewer = ImageViewer
self.Editor = Editor

self.theme = self.base.theme

def add_editor(self, editor) -> None:
self.__editors.add_editor(editor)
self.editors.add_editor(editor)

def open_editor(self, path=None, exists=True) -> None:
self.__editors.open_editor(path, exists)
self.editors.open_editor(path, exists)

def open_diff_editor(self, path, exists) -> None:
self.__editors.open_diff_editor(path, exists)
self.editors.open_diff_editor(path, exists)

def refresh(self) -> None:
self.__editors.refresh()
self.editors.refresh()

def active_editor(self):
return self.__editors.active_editor
return self.editors.active_editor

def set_active_editor(self, editor) -> None:
self.__editors.set_active_editor(editor)
self.editors.set_active_editor(editor)

def close_editor(self, editor) -> None:
self.__editors.close_editor(editor)
self.editors.close_editor(editor)

def close_active_editor(self) -> None:
self.__editors.close_active_editor()
self.editors.close_active_editor()
14 changes: 11 additions & 3 deletions biscuit/core/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ class Utils(Endpoint):
def __init__(self, *a) -> None:
super().__init__(*a)

self.Bubble = Bubble
self.Button = Button
self.ButtonsEntry = ButtonsEntry
self.caller_name = caller_name
self.Canvas = Canvas
self.get_codicon = get_codicon
self.colorize = colorize
self.Entry = Entry
self.FileType = FileType
self.get_codicon = get_codicon
self.FixedSizeStack = FixedSizeStack
self.Frame = Frame
self.Icon = Icon
self.IconButton = IconButton
self.IconLabelButton = IconLabelButton
self.Scrollbar = Scrollbar
self.Label = Label, TruncatedLabel, WrappingLabel
self.Menubutton = Menubutton
self.ScrollableFrame = ScrollableFrame
self.Scrollbar = Scrollbar
self.Shortcut = Shortcut
self.Text = Text
self.Toplevel = Toplevel
self.Tree = Tree
self.WrappingLabel = WrappingLabel
4 changes: 1 addition & 3 deletions biscuit/core/components/games/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
from .gameoflife import GameOfLife
from .minesweeper import Minesweeper
from .pong import Pong
from .snake import Snake
from .tetris import Tetris
from .ttt import TicTacToe
from .whoops import Whoops

games = {i.name:i for i in (Tetris, GameOfLife, Pong, TicTacToe, Snake, Minesweeper)}
games = {i.name:i for i in (GameOfLife, Pong, TicTacToe, Minesweeper)}


def get_games(base) -> list:
Expand Down
66 changes: 0 additions & 66 deletions biscuit/core/components/games/moonlander.py

This file was deleted.

Loading

0 comments on commit 5c93192

Please sign in to comment.