Open Forum > What's New

ScriptBasic for Android

<< < (15/15)

Support:
I added an ANSI screen attribute library to ScriptBasic. It runs fine on both Ubuntu and Android Linux.



Scripting the Android device remotely on Ubuntu.




--- Code: ---' SL4A and console screen mnemonics demo

IMPORT DVM
INCLUDE "ansi.inc"

CLS

PRINT GRAPHICS_ON
PRINT "l",STRING(38,"q"),"k"
FOR i = 2 TO 15
  PRINT AT(1,i),"x",AT(40,i),"x"
NEXT i
PRINTNL
PRINT "m",STRING(38,"q"),"j"
PRINT AT(1,3),"t",STRING(38,"q"),"u"
PRINT AT(30,3),"w"
FOR i = 4 TO 15
  PRINT AT(30,i),"x"
NEXT i
PRINT AT(30,i),"v"
PRINT GRAPHICS_OFF

PRINT AT(2,2),BOLD,COLOR(7,4,STRING(10," ") & "SAMSUNG Tab 2 10.1" & STRING(10," "))
PRINT AT(2,4),BOLD,COLOR(7,6," Phone Type" & STRING(17," "))
PRINT AT(2,5),BOLD,COLOR(7,6," Screen Brightness" & STRING(10," "))
PRINT AT(2,6),BOLD,COLOR(7,6," Airplane Mode" & STRING(14," "))
PRINT AT(2,7),BOLD,COLOR(7,6," Ringer Slient Mode" & STRING(9," "))
PRINT AT(2,8),BOLD,COLOR(7,6," Screen On" & STRING(18," "))
PRINT AT(2,9),BOLD,COLOR(7,6," Max Media Volume" & STRING(11," "))
PRINT AT(2,10),BOLD,COLOR(7,6," Max Ringer Volume" & STRING(10," "))
PRINT AT(2,11),BOLD,COLOR(7,6," Media Volume" & STRING(15," "))
PRINT AT(2,12),BOLD,COLOR(7,6," Ringer Volume" & STRING(14," "))
PRINT AT(2,13),BOLD,COLOR(7,6," Vibrate Mode" & STRING(15," "))
PRINT AT(2,14),BOLD,COLOR(7,6," Vibrate Mode Ringer" & STRING(8," "))
PRINT AT(2,15),BOLD,COLOR(7,6," Vibrate Mode Notify" & STRING(8," "))

PRINT AT(33,4),DVM::getPhoneType()
PRINT AT(33,5),DVM::getScreenBrightness()
IF DVM::checkAirplaneMode() = "false" THEN
  PRINT AT(33,6),COLOR(1,0,"false")
ELSE
  PRINT AT(33,6),COLOR(2,0,"true")
END IF
IF DVM::checkRingerSilentMode() = "false" THEN
  PRINT AT(33,7),COLOR(1,0,"false")
ELSE
  PRINT AT(33,7),COLOR(2,0,"true")
END IF
IF DVM::checkScreenOn() = "false" THEN
  PRINT AT(33,8),COLOR(1,0,"false")
ELSE
  PRINT AT(33,8),COLOR(2,0,"true")
END IF
PRINT AT(33,9),DVM::getMaxMediaVolume()
PRINT AT(33,10),DVM::getMaxRingerVolume()
PRINT AT(33,11),DVM::getMediaVolume()
PRINT AT(33,12),DVM::getRingerVolume()
IF DVM::getVibrateMode() = "false" THEN
  PRINT AT(33,13),COLOR(1,0,"false")
ELSE
  PRINT AT(33,13),COLOR(2,0,"true")
END IF
IF DVM::getVibrateMode(TRUE) = "false" THEN
  PRINT AT(33,14),COLOR(1,0,"false")
ELSE
  PRINT AT(33,14),COLOR(2,0,"true")
END IF
IF DVM::getVibrateMode(FALSE) = "false" THEN
  PRINT AT(33,15),COLOR(1,0,"false")
ELSE
  PRINT AT(33,15),COLOR(2,0,"true")
END IF

PRINT AT(1,18)
LINE INPUT z

--- End code ---

[*]CLS - Clear screen and home the cursor. (x1:y1)
[*]COLOR(fg,bg,text) - Set the foreground, background and text to be displayed in color.
[*]AT(x,y) - Position the cursor to the (x:y) position on the screen.
[*]NORMAL - Return attributes to the default state.
[*]BOLD - Bold the text follow the attribute.
[*]UNDERLINE_ON - Start underline text mode.
[*]UNDERLINE_OFF - End  underline text mode.
[*]REVERSE_ON - Start reverse video mode.
[*]REVERSE_OFF - End reverse video mode.
[*]INS - Insert a blank character at the current cursor position moving the text to the right.
[*]DEL - Delete a character at the current cursor position and shift text to the left.
[*]INS_LINE - Insert a blank line on the row the cursor is at and shift lines of text down.
[*]DEL_LINE - Delete a line on the row the cursor is at and shift lines of text up.
[*]GRAPHICS_ON - Switch to the graphics/line draw character set.
[*]GRAPHICS_OFF - Return back to the standard charater set.
[/list]

Note: All of the above screen attributes are in the form of a string. (except CLS)

ansi.inc

--- Code: ---' Console Display Enhancement Library

SUB CLS
  PRINT "\033[2J\033[1;1H"
END SUB

FUNCTION COLOR(fg,bg,text)
  COLOR = "\033[" & (fg + 30) & ";" & (bg + 40) & "m" & text & "\033[0m"
END FUNCTION

FUNCTION AT(x,y)
  AT = "\033[" & y & ";" & x & "H"
END FUNCTION

GLOBAL CONST NORMAL = "\033[22m"
GLOBAL CONST BOLD = "\033[1m"
GLOBAL CONST UNDERLINE_ON = "\033[4m"
GLOBAL CONST UNDERLINE_OFF = "\033[24m"
GLOBAL CONST REVERSE_ON = "\033[7m"
GLOBAL CONST REVERSE_OFF = "\033[27m"
GLOBAL CONST INS = "\033[1@"
GLOBAL CONST DEL = "\033[1P"
GLOBAL CONST INS_LINE = "\033[1L"
GLOBAL CONST DEL_LINE = "\033[1M"
GLOBAL CONST GRAPHICS_ON = "\033(0"
GLOBAL CONST GRAPHICS_OFF = "\033(B"

--- End code ---

Support:
If you have a Bluetooth keyboard for your Android device and the CAPS is sticking for you, download Dre’s Bluetooth Keyboard.apk to solve the problem. It worked for my Samsung Galaxy Tab 2 10.1 using ConnectBot and SL4A TERM. I didn't notice the problem as often with e-mail and browser forms. It seems the keyboard gets out of sync with the terminal app and works in the opposite way.

Navigation

[0] Message Index

[*] Previous page

Go to full version