Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2015-08-26
Editor fixes:
- now displays an i-beam/edit cursor
- highlighting for numbers and keywords
- F1 key for keywords surrounded by punctuation
- page scrolling with up/down arrow keys
- pressing tab at the bottom no longer jumps to the top
- display additional editor context menu items
Added a basic debugger

2015-08-02
Fix display output before DELAY
Fix LET command problem found in 32bit linux
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [0.11.19])
AC_INIT([smallbasic], [0.11.20])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand Down
2 changes: 1 addition & 1 deletion ide/android/assets/main.bas
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sub do_about()
print "(_ ._ _ _.|||_) /\ (_ |/ "
print "__)| | |(_||||_)/--\__)|\_"
print
print "Version 0.11.19"
print "Version 0.11.20"
print
print "Copyright (c) 2002-2015 Chris Warren-Smith"
print "Copyright (c) 1999-2006 Nic Christopoulos" + chr(10)
Expand Down
3 changes: 1 addition & 2 deletions samples/distro-examples/games/sokoban.levels
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
; $Id$
; Original sokoban levels
;

Expand Down Expand Up @@ -466,7 +465,7 @@


; 30
###########
###########
# # #
##### # $ $ #
# ##### $## # ##
Expand Down
13 changes: 6 additions & 7 deletions src/common/brun.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ void bc_loop(int isf) {
bcip_t next_ip;
int i;
int proc_level = 0;
byte trace_flag = 0;
byte code = 0;

// setup event checker time = 50ms
Expand Down Expand Up @@ -815,8 +814,8 @@ void bc_loop(int isf) {
continue;
case kwTYPE_LINE:
prog_line = code_getaddr();
if (trace_flag) {
dev_printf("<%d>", prog_line);
if (opt_trace_on) {
dev_trace_line(prog_line);
}
continue;
case kwLET:
Expand Down Expand Up @@ -1031,10 +1030,10 @@ void bc_loop(int isf) {
cmd_fseek();
break;
case kwTRON:
trace_flag = 1;
opt_trace_on = 1;
continue;
case kwTROFF:
trace_flag = 0;
opt_trace_on = 0;
continue;
case kwSTOP:
case kwEND:
Expand Down Expand Up @@ -1088,8 +1087,8 @@ void bc_loop(int isf) {
prog_ip++;
if (code == kwTYPE_LINE) {
prog_line = code_getaddr();
if (trace_flag) {
dev_printf("<%d>", prog_line);
if (opt_trace_on) {
dev_trace_line(prog_line);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/common/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,9 @@ void v_create_form(var_p_t var) {}
void v_create_window(var_p_t var) {}
void dev_show_page() {}
#endif

#if !defined(_SDL)
void dev_trace_line(int lineNo) {
dev_printf("<%d>", lineNo);
}
#endif
7 changes: 7 additions & 0 deletions src/common/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,13 @@ void dev_destroy_file_list(char_p_t *list, int count);
*/
dword dev_get_millisecond_count();

/**
* @ingroup dev_f
*
* Trace or debug at the given line number
*/
void dev_trace_line(int lineNo);

#if defined(__cplusplus)
}
#endif
Expand Down
12 changes: 10 additions & 2 deletions src/common/inet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <errno.h>
#include <sys/types.h>

#if defined(__cplusplus)
extern "C" {
#endif

typedef int socket_t;

/**
Expand Down Expand Up @@ -120,11 +124,15 @@ void net_disconnect(socket_t s);
/**
* @ingroup net
*
* returns true if something is waitting in input-buffer
* returns true if something is waiting in input-buffer
*
* @param s the socket
* @return non-zero if something is waitting in input-buffer; otherwise returns 0
* @return non-zero if something is waiting in input-buffer; otherwise returns 0
*/
int net_peek(socket_t s);

#if defined(__cplusplus)
}
#endif

#endif
1 change: 1 addition & 0 deletions src/common/pproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define PV_FILE 1
#define PV_LOG 2
#define PV_STRING 3
#define PV_NET 4

#if defined(__cplusplus)
extern "C" {
Expand Down
4 changes: 4 additions & 0 deletions src/common/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "common/sys.h"
#include "common/pproc.h"
#include "common/messages.h"
#include "common/inet.h"
#include <limits.h>

/*
Expand Down Expand Up @@ -254,6 +255,9 @@ void pv_write(char *str, int method, int handle) {
}
strcat((char *) vp->v.p.ptr, str);
break;
case PV_NET:
net_print((socket_t) handle, (const char *)str);
break;
default:
dev_print(str);
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/smbas.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ EXTERN byte opt_usepcre; /**< OPTION PREDEF PCRE */
EXTERN byte opt_file_permitted; /**< file system permission */
EXTERN byte opt_show_page; /**< SHOWPAGE graphics flush mode */
EXTERN byte opt_mute_audio; /**< whether to mute sounds */
EXTERN byte opt_antialias; /**< OPTION ANTIALIAS OFF */
EXTERN byte opt_antialias; /**< OPTION ANTIALIAS OFF */
EXTERN byte opt_trace_on; /**< initial value for the TRON command */

#define IDE_NONE 0
#define IDE_INTERNAL 1
Expand Down
4 changes: 3 additions & 1 deletion src/lib/stb_textedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditStat
#ifdef STB_TEXTEDIT_IS_SPACE
static int is_word_boundary( STB_TEXTEDIT_STRING *_str, int _idx )
{
return _idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str,_idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str, _idx) ) ) : 1;
return _idx > 0 ? ((STB_TEXTEDIT_IS_SPACE(STB_TEXTEDIT_GETCHAR(_str,_idx-1)) ||
STB_TEXTEDIT_IS_PUNCT(STB_TEXTEDIT_GETCHAR(_str,_idx-1))) &&
!STB_TEXTEDIT_IS_SPACE(STB_TEXTEDIT_GETCHAR(_str, _idx))) : 1;
}

static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, STB_TexteditState *_state )
Expand Down
1 change: 1 addition & 0 deletions src/platform/android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LOCAL_SRC_FILES := main.cpp \
../../../ui/textedit.cpp \
../../../ui/strlib.cpp \
../../../ui/graphics.cpp \
../../../ui/editor.cpp \
../../../ui/system.cpp
LOCAL_LDLIBS := -llog -landroid -ljnigraphics
LOCAL_STATIC_LIBRARIES := sb_common freetype android_native_app_glue
Expand Down
2 changes: 2 additions & 0 deletions src/platform/android/jni/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

Runtime *runtime;

void launchDebug(const char *file) {}

MAEvent *getMotionEvent(int type, AInputEvent *event) {
MAEvent *result = new MAEvent();
result->type = type;
Expand Down
5 changes: 4 additions & 1 deletion src/platform/android/jni/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct Runtime : public System {
int ask(const char *title, const char *prompt, bool cancel);
void clearSoundQueue();
void construct();
void debugStart(TextEditInput *edit, const char *file) {}
void debugStep(TextEditInput *edit, TextEditHelpWidget *help, bool cont) {}
void debugStop() {}
bool getUntrusted();
String getString(const char *methodName);
int getInteger(const char *methodName);
Expand All @@ -44,7 +47,7 @@ struct Runtime : public System {
char *loadResource(const char *fileName);
void optionsBox(StringList *items);
void setWindowTitle(const char *title) {}
void showCursor(bool hand) {}
void showCursor(CursorType cursorType) {}
void showKeypad(bool show);
void onResize(int w, int h);
void loadConfig();
Expand Down
1 change: 1 addition & 0 deletions src/platform/sdl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sbasicg_SOURCES = \
../../ui/window.cpp \
../../ui/screen.cpp \
../../ui/system.cpp \
../../ui/editor.cpp \
../../ui/form.cpp \
../../ui/inputs.cpp \
../../ui/textedit.cpp \
Expand Down
70 changes: 53 additions & 17 deletions src/platform/sdl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ const char* FONTS[] = {
};

static struct option OPTIONS[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"keywords", no_argument, NULL, 'k'},
{"command", optional_argument, NULL, 'c'},
{"font", optional_argument, NULL, 'f'},
{"run", optional_argument, NULL, 'r'},
{"module", optional_argument, NULL, 'm'},
{"edit", optional_argument, NULL, 'e'},
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"keywords", no_argument, NULL, 'k'},
{"command", optional_argument, NULL, 'c'},
{"font", optional_argument, NULL, 'f'},
{"run", optional_argument, NULL, 'r'},
{"module", optional_argument, NULL, 'm'},
{"edit", optional_argument, NULL, 'e'},
{"debug", optional_argument, NULL, 'd'},
{"debugPort", optional_argument, NULL, 'p'},
{0, 0, 0, 0}
};

const char *CONFIG_NAME = "SmallBASIC";
char g_appPath[OS_PATHNAME_SIZE + 1];
int g_debugPort = 4000;

void appLog(const char *format, ...) {
char buf[4096], *p = buf;
Expand Down Expand Up @@ -206,6 +209,22 @@ void printKeywords() {
}
}

void setupAppPath(const char *path) {
g_appPath[0] = '\0';
if (path[0] == '/' || (path[1] == ':' && path[2] == '\\')) {
// full path or C:/
strcpy(g_appPath, path);
} else {
// relative path
char cwd[OS_PATHNAME_SIZE + 1];
cwd[0] = '\0';
getcwd(cwd, sizeof(cwd) - 1);
strcpy(g_appPath, cwd);
strcat(g_appPath, "/");
strcat(g_appPath, path);
}
}

void showHelp() {
fprintf(stdout,
"SmallBASIC version %s - kw:%d, pc:%d, fc:%d, ae:%d I=%d N=%d\n\n",
Expand All @@ -226,20 +245,20 @@ void showHelp() {
int main(int argc, char* argv[]) {
logEntered();

setupAppPath(argv[0]);
opt_command[0] = '\0';
opt_verbose = false;
opt_quiet = true;

char *fontFamily = NULL;
char *runFile = NULL;
bool debug = false;
int fontScale;
SDL_Rect rect;

restoreSettings(CONFIG_NAME, rect, fontScale);

while (1) {
int option_index = 0;
int c = getopt_long(argc, argv, "hvkc:f:r:m:e:", OPTIONS, &option_index);
int c = getopt_long(argc, argv, "hvkc:f:r:m:e:d:p:", OPTIONS, &option_index);
if (c == -1) {
// no more options
if (!option_index) {
Expand All @@ -257,9 +276,17 @@ int main(int argc, char* argv[]) {
}
break;
}
if (OPTIONS[option_index].has_arg && !optarg) {
showHelp();
exit(1);

int i = 0;
while (OPTIONS[i].name != NULL) {
if (OPTIONS[i].has_arg && OPTIONS[i].val == c &&
(!optarg || strcmp(OPTIONS[i].name + 1, optarg) == 0)) {
// no arg or passed single '-' for long form arg
showHelp();
exit(1);
break;
}
i++;
}
switch (c) {
case 'v':
Expand All @@ -284,6 +311,14 @@ int main(int argc, char* argv[]) {
opt_loadmod = 1;
strcpy(opt_modlist, optarg);
break;
case 'd':
runFile = strdup(optarg);
opt_ide = IDE_EXTERNAL;
debug = true;
break;
case 'p':
g_debugPort = atoi(optarg);
break;
case 'h':
showHelp();
exit(1);
Expand All @@ -298,6 +333,7 @@ int main(int argc, char* argv[]) {
}
}

restoreSettings(rect, fontScale, debug);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
SDL_Window *window = SDL_CreateWindow("SmallBASIC",
rect.x, rect.y, rect.w, rect.h,
Expand All @@ -311,12 +347,12 @@ int main(int argc, char* argv[]) {
loadIcon(window);
Runtime *runtime = new Runtime(window);
runtime->construct(font.c_str(), fontBold.c_str());
fontScale = runtime->runShell(runFile, fontScale);
fontScale = runtime->runShell(runFile, fontScale, debug ? g_debugPort : 0);
delete runtime;
} else {
fprintf(stderr, "Failed to locate display font\n");
}
saveSettings(CONFIG_NAME, window, fontScale);
saveSettings(window, fontScale, debug);
SDL_DestroyWindow(window);
} else {
fprintf(stderr, "Could not create window: %s\n", SDL_GetError());
Expand Down
Loading