Code Monkey home page Code Monkey logo

kojo's Introduction

Kojo Links

To start hacking:

  • Make sure you have Java 8 on your path.
  • Run ./sbt.sh clean package to build Kojo.
  • Run ./sbt.sh test to run the Kojo unit tests.
  • Run ./sbt.sh run to run Kojo (use net.kogics.kojo.lite.DesktopMain as the main class)
  • As you modify the code, do incremental (and fast) auto-compilation and auto-testing using sbt:
sbt
  > ~compile
  > ~test

IDE setup

Intellij IDEA

Do a File -> New -> Project from Existing Sources and import/open the root folder of the Kojo repo. Then import the new project via sbt.

Emacs

Put the following in your .emacs config file:

;; cd ~/src; git clone https://github.com/jwiegley/use-package
(eval-when-compile
  (add-to-list 'load-path "~/src/use-package")
  (require 'use-package))
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
;; https://github.com/hvesalai/emacs-scala-mode
(use-package scala-mode
  :interpreter
    ("scala" . scala-mode))
(add-to-list 'auto-mode-alist '("\\.sc\\'" . scala-mode))
(add-to-list 'auto-mode-alist '("\\.kojo\\'" . scala-mode))

kojo's People

Contributors

litan avatar bulent2k2 avatar ezoerner avatar christophknabe avatar idarasmark avatar mikolajs avatar samijaber avatar kamatanay avatar guillermoovejerosanchez avatar mushtaq avatar argalad avatar glixx avatar alexitc avatar bjornregnell avatar gps95 avatar marcusklang avatar

Stargazers

Tushar Gupta avatar Kishore avatar Eli Bird avatar Zhangmw avatar strobe avatar  avatar  avatar  avatar  avatar  avatar Gunther Wittig avatar Oleg Mirzov avatar Chad Selph avatar Nekoppoi avatar mikaela avatar  avatar scalway avatar Sören Brunk avatar xenia avatar Sergey Durmanov avatar lei_xxx avatar Volkan TAŞ avatar  avatar  avatar spamegg avatar  avatar Heerdyes Mahapatro avatar Virgilio Stefanin  avatar Sakib Hadžiavdić avatar  avatar  avatar ebigram avatar Ramiro Calle avatar Ihor avatar jison avatar  avatar Arnim Rupp avatar Luis Kao avatar Siyan Xiong avatar charis avatar ShankarShastri avatar  avatar  avatar  avatar Daniel Sokil avatar  avatar Ola Flisbäck avatar Dmitry Lisovsky avatar  avatar  avatar MPA avatar Sergei Dovzhikov avatar No Spam avatar josemanuelp avatar Daniel Dugovic avatar Tongfei Chen avatar Sanket Patil avatar Tushar Bihani avatar Alexandre Mathieu avatar Smrutiranjan Sahu avatar Carlos Rueda avatar Brandon Elam Barker avatar Shane Delmore avatar Shubham Kamthania avatar  avatar  avatar  avatar Caleb Jenkins avatar

Watchers

 avatar Anzu avatar James Cloos avatar Brandon Elam Barker avatar James Shen avatar  avatar  avatar lei_xxx avatar  avatar

kojo's Issues

Exception when using a touch screen laptop

The exception happens when we touch the canvas during Showcase/Tic Tac Toe (or Othello) instead of using the left mouse button to click. The good news is that it doesn't break the game. However, each touch event results in an exception and a long stack trace.

Note that touching the Run button on the script editor works OK.

Here is the log file:

error-at-first-touch-tic-tac-toe.log

java 11 support? (or some other -- novice -- issue?)

Hi,

I attempted my first compilation and got an error:

[error] /Users/ben/src/kojo/git/kojo/src/main/scala/net/kogics/kojo/lite/MacTweaks.scala:25: type mismatch;
[error]  found   : com.apple.eawt.AboutHandler
[error]  required: java.awt.desktop.AboutHandler
[error]     app.setAboutHandler(new AboutHandler {

Here is the version of java I have:

ben@Bulents-MacBook-Pro kojo % java --version
java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

Thanks so much,
Bulent

TestAPI with core-builtins code

"To get access to builtins in a test, the best way is to probably build up a stub code execution context."

We would like to provide a basic test that uses builtins (assuming no such test already exists.) So that we could test many commands that depend on builtins. e.g. epochTime.

At the moment, calling any such command results in a runtime error (compiler is not able to catch this problem):

[info] - Translation of java.util.Calendar and System.nanoTime etc to work *** FAILED ***
[info]   java.lang.NullPointerException:
[info]   at net.kogics.kojo.lite.i18n.TurkishAPI$.buAn(trInit.scala:237)
[info]   at net.kogics.kojo.lite.i18n.TurkishAPITest.$anonfun$new$121(TurkishAPITest.scala:686)
[info]   at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
[info]   at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:186)
[info]   at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
[info]   at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
[info]   ...

Doesn't work on Java 9.0.4 and 10.0.1

Exception in thread "main" java.lang.ExceptionInInitializerError
at net.kogics.kojo.lite.DesktopMain.main(DesktopMain.scala)
Caused by: java.lang.RuntimeException: classloader (jdk.internal.loader.ClassLoaders$AppClassLoader@6d5380c2) is not a URLClassLoader
at scala.sys.package$.error(package.scala:27)
at net.kogics.kojo.lite.DesktopMain$.(DesktopMain.scala:23)
at net.kogics.kojo.lite.DesktopMain$.(DesktopMain.scala)
... 1 more

IntelliSense (feature request / discussion)

I know this probably isn't an easy one to do, but, it may be worthwhile. The most important subset of intellisense I think, is the ability to look up documentation within the editor for given types, functions, etc.

Kojo gets stuck in fullscreen in MacOS

Had to reboot the macbook. No key or key combo worked. Esc, Cmd-Tab, Cmd-Ctr-F.

The code that's the culprit is rather simple (see below).

It worked fine until I switched to full screen and then back, turned on the axes (not sure that's relevant, but just to capture the sequence of events. I will write again after root-causing this), turned the axes off again and the keys (defined below) stopped working. I then switch it to full screen using the context menu (stupid thing to do, but, that's hindsight for you :-) and got stuck. Now that I captured this so far, let me try to reproduce it. Wish me luck.

onKeyPress {
    case 90 => { // pressed z
        removeLastPoint()
        println(points.size + " points now")
    }
    case 67 => { // pressed c
        if (emptyStack()) { println("stack empty now") }
        else {
            val oldPoint = popFromStack()
            points.append(oldPoint)
            println(s"${points.size}")
            if (points.size > 2) {
                drawTriangles()
            }
        }
    }
    case 88 => { // pressed x
        while (!emptyStack) removedPoints.pop
        println("empty")
    }
    case a => println(s"$a")
}

error when running readInt

when running the following simple code, an error occurs. My system is win10.

import io.StdIn
val r = StdIn.readInt

error (from the log)
Problem
java.io.EOFException: Console has reached end of input
at scala.io.StdIn.readInt(StdIn.scala:120)
at scala.io.StdIn.readInt$(StdIn.scala:117)
at scala.io.StdIn$.readInt(StdIn.scala:241)
at Wrapper3$.(scripteditor:13)
at Wrapper3$.(scripteditor)
at Wrapper3.entry(scripteditor)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

file reader fails to read Turkish chars correctly in Windows build

//#yükle tr/sozcuk-dizinini-yukle
cleari
val dict: List[String] = sözcükDizininiYükle
val wrong = dict(2)
val right = "abacı" // "ı" is a Turkish char
println(wrong)
write(wrong)

This is used in the anagram sample. It works in MacOS builds, but fails on Windows machines.

ammonite style import $file, import $exec, import $ivy

Would it make sense to enhance Kojo to support modular scripting features in ammonite like import $file, $exec and $ivy?

Is there an alternative available to use now for modular development of bigger scripts in Kojo?

localize worksheet REPL output

In Turkish, a simple example from the scala tutorial is:

val n = new Nokta(3, 4) //> val n: Nokta = Nokta@98f03a4
n.x //> val res1: TurkishAPI.Sayı = 3

It would help readability to remove TurkishAPI. and return only the type alias (type Sayı = Int and Nokta is Turkish for Point) as follows:
p.x //> val res1: Sayı

I hope this is not too involved? Either way, please let me know a few pointers and I can work on it..

Code formatter fails when an underscore is used in a big number

Here is a sample:

clearOutput
val big= 200_000_000
println(big / 100_000.0)

This code compiles and runs. However, when we run "Format Source" command, we get an error:
Unable to format: Invalid literal number: _
and the formatter fails to format the code.

Localization for interactively changing color

Right clicking with the mouse (tapping with two fingers on the touch pad) on any color or numerical value in the code editor lets us manipulate drawings on canvas interactively. E.g.,

// Click on yellow with right mouse button to bring up color editor:
val c = yellow

Please enhance the code to support the local language. E.g., in Turkish, we have:

val c = sarı

Thank you so much!
B

workspace eval printed in the wrong line

Below is a sample. The REPL result for the code val x = 3 is appended at the end of the first multi-line comment.

/*
 *           [b]
 *          /  \
 *        [a]  c,20
 *       /  \
 *     a,30  b,10       
 */      //> val x: Int = 3

/* what's going on? */
 
val x = 3

Latest release hangs on macOS at the splash screen

It gets stuck at the splash screen (displaying the circle of colorful squares and the text: Loading...) and Kojo never starts up.

Version: 2.9.22

Tried on two machines:

  1. MacBook Pro laptop running macOS Monterey Version 12.5 and
  2. MacBook Air running macOS Catalina Version 10.15.7

My own build from the latest comes up fine on machine (1).

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.