Skip to content

Commit

Permalink
chore: fix compiler warnings and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ianatha committed Nov 11, 2023
1 parent aa6410d commit b889d91
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 59 deletions.
55 changes: 0 additions & 55 deletions app/src/main/java/io/atha/bababasic/ActivityMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -432,61 +432,6 @@ class ActivityMain : AppCompatActivity() {
}
}

private val EXAMPLES = mapOf(
"HELLO.bas" to """PRINT "HELLO WORLD"
PRINT "Καλημέρα κόσμε"
PRINT "ハローワールド"
INPUT "Name? ", A$
PRINT "HELLO " + A$
""",
"PRIME.bas" to """FOR I% = 1 TO 10000
J% = 3
N% = I% \ 2
ISPRIME% = (I% > 1) AND ((I% MOD 2 <> 0) OR (I% = 2))
WHILE J% <= N% AND ISPRIME% = -1
ISPRIME% = I% MOD J% <> 0
J% = J% + 2
WEND
IF ISPRIME% THEN PRINT STR$(I%), " is prime"
NEXT I%
""",
"FIB.bas" to """10 LET A = 0
20 LET B = 1
30 LET C = A + B
40 PRINT C
50 LET A = B
60 LET B = C
65 SLEEP 0.5
70 GOTO 30
""",
"INKEY.bas" to """PRINT "PRESS w,a,s,d TO MOVE THE STAR. PRESS q to QUIT."
X = 5
Y = 5
eventLoop:
LOCATE 2
FOR I = 0 TO 10
FOR J = 0 TO 10
IF X = I AND Y = J THEN PRINT "*"; ELSE PRINT " ";
NEXT J
PRINT
NEXT I
A$ = INKEY$
IF A$ <> "" THEN BEGIN
LOCATE 15
PRINT "YOU PRESSED " + A$
IF A$ = "a" THEN Y = Y - 1
IF A$ = "d" THEN Y = Y + 1
IF A$ = "w" THEN X = X - 1
IF A$ = "s" THEN X = X + 1
IF A$ = "q" THEN END
END IF
IF X < 0 THEN X = 0
IF X > 10 THEN X = 10
IF Y < 0 THEN Y = 0
IF Y > 10 THEN Y = 10
GOTO eventLoop"""
)

private val defaultScript = EXAMPLES["HELLO.bas"]!!

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
61 changes: 61 additions & 0 deletions app/src/main/java/io/atha/bababasic/EXAMPLES.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.atha.bababasic

val EXAMPLES = mapOf(
"HELLO.bas" to """PRINT "Hello, world!"
PRINT "Καλημέρα, κόσμε!"
PRINT "ハロー, ワールド!"
PRINT
INPUT "Name? ", A$
PRINT "Hello, ", A$, "!"
INPUT "Year of birth? ", YOB%
CURRENTYEAR% = VAL(RIGHT${'$'}(DATE${'$'}, 4))
AGE% = CURRENTYEAR% - YOB%
PRINT "Your age is", AGE%
""",
"PRIME.bas" to """FOR I% = 1 TO 10000
J% = 3
N% = I% \ 2
ISPRIME% = (I% > 1) AND ((I% MOD 2 <> 0) OR (I% = 2))
WHILE J% <= N% AND ISPRIME% = -1
ISPRIME% = I% MOD J% <> 0
J% = J% + 2
WEND
IF ISPRIME% THEN PRINT STR$(I%), " is prime"
NEXT I%
""",
"FIB.bas" to """10 LET A = 0
20 LET B = 1
30 LET C = A + B
40 PRINT C
50 LET A = B
60 LET B = C
65 SLEEP 0.5
70 GOTO 30
""",
"INKEY.bas" to """PRINT "PRESS w,a,s,d TO MOVE THE STAR. PRESS q to QUIT."
X = 5
Y = 5
eventLoop:
LOCATE 2
FOR I = 0 TO 10
FOR J = 0 TO 10
IF X = I AND Y = J THEN PRINT "*"; ELSE PRINT " ";
NEXT J
PRINT
NEXT I
A$ = INKEY$
IF A$ <> "" THEN BEGIN
LOCATE 15
PRINT "YOU PRESSED " + A$
IF A$ = "a" THEN Y = Y - 1
IF A$ = "d" THEN Y = Y + 1
IF A$ = "w" THEN X = X - 1
IF A$ = "s" THEN X = X + 1
IF A$ = "q" THEN END
END IF
IF X < 0 THEN X = 0
IF X > 10 THEN X = 10
IF Y < 0 THEN Y = 0
IF Y > 10 THEN Y = 10
GOTO eventLoop"""
)
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ class TermuxTerminalViewClient(
return
}
val urls = urlSet.toTypedArray()
Collections.reverse(Arrays.asList(*urls)) // Latest first.
mutableListOf(*urls).reverse() // Latest first.

// Click to copy url to clipboard:
val dialog: AlertDialog = AlertDialog.Builder(mActivity).setItems(
Expand All @@ -659,7 +659,7 @@ class TermuxTerminalViewClient(
val lv =
dialog.listView // this is a ListView with your "buds" in it
lv.onItemLongClickListener =
AdapterView.OnItemLongClickListener { parent: AdapterView<*>?, view: View?, position: Int, id: Long ->
AdapterView.OnItemLongClickListener { _: AdapterView<*>?, _: View?, position: Int, _: Long ->
dialog.dismiss()
val url = urls[position] as String
ShareUtils.openUrl(mActivity, url)
Expand All @@ -677,14 +677,14 @@ class TermuxTerminalViewClient(
mActivity, TermuxConstants.TERMUX_APP_NAME + " Report Issue",
"debug info?", //mActivity.getString(R.string.msg_add_termux_debug_info),
"yes", // mActivity.getString(R.string.action_yes),
{ dialog: DialogInterface?, which: Int ->
{ _: DialogInterface?, _: Int ->
reportIssueFromTranscript(
transcriptText,
true
)
},
"no", //mActivity.getString(R.string.action_no),
{ dialog: DialogInterface?, which: Int ->
{ _: DialogInterface?, _: Int ->
reportIssueFromTranscript(
transcriptText,
false
Expand Down

0 comments on commit b889d91

Please sign in to comment.