diff --git a/appinfo.json b/appinfo.json index ba6d12f..dcfa861 100644 --- a/appinfo.json +++ b/appinfo.json @@ -3,9 +3,9 @@ "capabilities": [ "" ], - "companyName": "Michael E.", - "enableMultiJS": true, - "longName": "Calculator", + "companyName": "Save V.", + "enableMultiJS": false, + "longName": "PebbLisp", "projectType": "native", "resources": { "media": [ @@ -19,13 +19,13 @@ ] }, "sdkVersion": "3", - "shortName": "Calculator", + "shortName": "PebbLisp", "targetPlatforms": [ "aplite", "basalt" ], "uuid": "3a239ae0-adc5-4d40-b871-6fbcd8c37e7c", - "versionLabel": "1.1", + "versionLabel": "0.1", "watchapp": { "watchface": false } diff --git a/calcers.vims b/calcers.vims new file mode 100644 index 0000000..40c1d01 --- /dev/null +++ b/calcers.vims @@ -0,0 +1,518 @@ +let SessionLoad = 1 +if &cp | set nocp | endif +vnoremap  "+y +nnoremap  "+yy +nnoremap   +nnoremap  ^ +let s:cpo_save=&cpo +set cpo&vim +nnoremap  +nnoremap   +nnoremap   +nnoremap  m`v$hp``y$ +nnoremap ! :! +nnoremap "p "0p +nnoremap // m`I//``:s-////-- +nnoremap :W :w +nnoremap U ~ +nnoremap \n :tabedit~/.notes +nnoremap \v :tabedit~/.vimrc +nnoremap \r :source ~/.vimrc +nnoremap \ga :!git add % +nnoremap \gu :!git add -u +nnoremap \gp :!git push +nnoremap \gl :!git log +nnoremap \gh :!git --help +nnoremap \gc :!git commit -m "" +nnoremap \gB :!git blame % +nnoremap \gD :!git diff +nnoremap \gd :!git diff % +nnoremap \p :w :!make run +nnoremap \c :!cat % | xclip -selection clipboard +vnoremap \PP :ha > ~/.vim.ps :!xdg-open ~/.vim.ps +nnoremap \PP :ha > ~/.vim.ps :!xdg-open ~/.vim.ps +nnoremap \b :ls :b +nnoremap ciw cw +nnoremap cw ciw +nnoremap dh d^ +nnoremap dl d$ +vmap gx NetrwBrowseXVis +nmap gx NetrwBrowseX +nnoremap gb dawbP +nnoremap gs "xdiwdwep"xp +nnoremap yh y^ +nnoremap yl y$ +nnoremap ~ U +vnoremap NetrwBrowseXVis :call netrw#BrowseXVis() +nnoremap NetrwBrowseX :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '')),netrw#CheckIfRemote()) +inoremap  +inoremap jk l +inoremap jj l +inoremap kj l +cnoreabbr vimc tabedit ~/.vimrc +cabbr %% expand('%:p:h') +iabbr reutner return +iabbr reteun return +iabbr ruetn return +let &cpo=s:cpo_save +unlet s:cpo_save +set autoindent +set background=dark +set backspace=indent,eol,start +set dictionary=/usr/share/dict/words +set expandtab +set fileencodings=ucs-bom,utf-8,default,latin1 +set foldlevelstart=5 +set helplang=en +set ignorecase +set printoptions=paper:a4 +set ruler +set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after +set shiftwidth=4 +set smartcase +set smartindent +set smarttab +set splitbelow +set splitright +set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc +set tags=./tags;/ +set thesaurus=~/.vim/thesaurus/thesaurus-vim-en +set window=44 +let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0 +let v:this_session=expand(":p") +silent only +cd ~/work/PebbleCalc +if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' + let s:wipebuf = bufnr('%') +endif +set shortmess=aoO +badd +34 src/pebblisp.h +badd +3 src/pebblisp.c +badd +0 ~/work/PebbleCalc/src/calc.c +argglobal +silent! argdel * +$argadd src/pebblisp.h +edit ~/work/PebbleCalc/src/calc.c +set splitbelow splitright +wincmd _ | wincmd | +vsplit +1wincmd h +wincmd w +wincmd _ | wincmd | +split +1wincmd k +wincmd w +wincmd t +set winminheight=1 winheight=1 winminwidth=1 winwidth=1 +exe 'vert 1resize ' . ((&columns * 76 + 76) / 153) +exe '2resize ' . ((&lines * 21 + 22) / 45) +exe 'vert 2resize ' . ((&columns * 76 + 76) / 153) +exe '3resize ' . ((&lines * 21 + 22) / 45) +exe 'vert 3resize ' . ((&columns * 76 + 76) / 153) +argglobal +setlocal keymap= +setlocal noarabic +setlocal autoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e +setlocal cinoptions= +setlocal cinwords=if,else,while,do,for,switch +setlocal colorcolumn= +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal expandtab +if &filetype != 'c' +setlocal filetype=c +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=5 +setlocal foldmarker={{{,}}} +set foldmethod=syntax +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal shiftwidth=4 +setlocal noshortname +setlocal signcolumn=auto +setlocal smartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'c' +setlocal syntax=c +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tags= +setlocal termkey= +setlocal termsize= +setlocal textwidth=0 +setlocal thesaurus= +setlocal noundofile +setlocal undolevels=-123456 +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +21 +normal! zo +61 +normal! zo +61 +normal! zo +let s:l = 6 - ((5 * winheight(0) + 21) / 43) +if s:l < 1 | let s:l = 1 | endif +exe s:l +normal! zt +6 +normal! 021| +wincmd w +argglobal +if bufexists('src/pebblisp.c') | buffer src/pebblisp.c | else | edit src/pebblisp.c | endif +setlocal keymap= +setlocal noarabic +setlocal autoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e +setlocal cinoptions= +setlocal cinwords=if,else,while,do,for,switch +setlocal colorcolumn= +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal expandtab +if &filetype != 'c' +setlocal filetype=c +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=5 +setlocal foldmarker={{{,}}} +set foldmethod=syntax +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal shiftwidth=8 +setlocal noshortname +setlocal signcolumn=auto +setlocal smartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'c' +setlocal syntax=c +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tags= +setlocal termkey= +setlocal termsize= +setlocal textwidth=0 +setlocal thesaurus= +setlocal noundofile +setlocal undolevels=-123456 +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +4 +normal! zo +10 +normal! zo +11 +normal! zo +let s:l = 29 - ((20 * winheight(0) + 10) / 21) +if s:l < 1 | let s:l = 1 | endif +exe s:l +normal! zt +29 +normal! 017| +wincmd w +argglobal +if bufexists('src/pebblisp.h') | buffer src/pebblisp.h | else | edit src/pebblisp.h | endif +setlocal keymap= +setlocal noarabic +setlocal autoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e +setlocal cinoptions= +setlocal cinwords=if,else,while,do,for,switch +setlocal colorcolumn= +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal expandtab +if &filetype != 'cpp' +setlocal filetype=cpp +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=5 +setlocal foldmarker={{{,}}} +set foldmethod=syntax +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal shiftwidth=8 +setlocal noshortname +setlocal signcolumn=auto +setlocal smartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'cpp' +setlocal syntax=cpp +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tags= +setlocal termkey= +setlocal termsize= +setlocal textwidth=0 +setlocal thesaurus= +setlocal noundofile +setlocal undolevels=-123456 +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +15 +normal! zo +18 +normal! zo +let s:l = 19 - ((4 * winheight(0) + 10) / 21) +if s:l < 1 | let s:l = 1 | endif +exe s:l +normal! zt +19 +normal! 014| +wincmd w +exe 'vert 1resize ' . ((&columns * 76 + 76) / 153) +exe '2resize ' . ((&lines * 21 + 22) / 45) +exe 'vert 2resize ' . ((&columns * 76 + 76) / 153) +exe '3resize ' . ((&lines * 21 + 22) / 45) +exe 'vert 3resize ' . ((&columns * 76 + 76) / 153) +tabnext 1 +if exists('s:wipebuf') + silent exe 'bwipe ' . s:wipebuf +endif +unlet! s:wipebuf +set winheight=1 winwidth=20 shortmess=filnxtToO +set winminheight=1 winminwidth=1 +let s:sx = expand(":p:r")."x.vim" +if file_readable(s:sx) + exe "source " . fnameescape(s:sx) +endif +let &so = s:so_save | let &siso = s:siso_save +doautoall SessionLoadPost +unlet SessionLoad +" vim: set ft=vim : diff --git a/resources/images/appicon.png b/resources/images/appicon.png index 3948a49..65e044b 100644 Binary files a/resources/images/appicon.png and b/resources/images/appicon.png differ diff --git a/src/.pebblisp.c.swp b/src/.pebblisp.c.swp new file mode 100644 index 0000000..f15e356 Binary files /dev/null and b/src/.pebblisp.c.swp differ diff --git a/src/.pebblisp.h.swp b/src/.pebblisp.h.swp new file mode 100644 index 0000000..14ae095 Binary files /dev/null and b/src/.pebblisp.h.swp differ diff --git a/src/calc.c b/src/calc.c index 6aa1365..64f9f75 100644 --- a/src/calc.c +++ b/src/calc.c @@ -10,18 +10,12 @@ static inline char* getToken(int n) { } static int8_t selected_token = 1; //Currently selected button, starts on '5' - -// static bool operator_entered = false; //Has the operator been entered yet -// static bool num1_is_ans = false; //Is the previous result in num1? Used to allow further calculations on result. -// static char num1[MAX_LENGTH] = ""; //First operand -// static char num2[MAX_LENGTH] = ""; //Second operand -// static char result_text[MAX_LENGTH] = ""; //Results text layer buffer string -// static uint8_t operator = 0; //Operator, where 0 is +, 1 is -, 2 is *, 3 is /, 4 is ^ static struct Environment env; static void updateText() { strcpy(temptext, mytext); + if(getToken(selected_token)[0] == ' ') { strcat(temptext, "_"); } else { @@ -31,11 +25,11 @@ static void updateText() text_layer_set_text(s_input_text_layer, temptext); } -//Up or Down button handler +// Button handler static void up_down_handler(ClickRecognizerRef recognizer, void *context){ - //Move selected button down if down is pressed, and up if up is pressed + // Change current token selected_token += (click_recognizer_get_button_id(recognizer) == BUTTON_ID_DOWN) ? 1 : -1; - //If selected button is outside button range, wrap around + // If selected token is outside of range, wrap around selected_token = selected_token < 0 ? TOKEN_END : selected_token > TOKEN_END ? 0 : selected_token; updateText(); @@ -48,70 +42,13 @@ static void enter(){ updateText(); } -// // Backspace. Clears whole number if full is true -// static void clear(bool full){ -// char *num = operator_entered ? num2 : num1; //Create a pointer to the currently edited number -// if(full) -// *num = 0; -// else -// num[strlen(num)-1] = 0; -// text_layer_set_text(s_input_text_layer, num); -// } - //Calculate result, display it and reset static void calculate(){ - // Object obj = parseEval(mytext, &env); - // snprintf(mytext, MAX_LENGTH, "R:%d", obj.number); - // selected_token = 0; - strcpy(mytext, "heythere"); + Object obj = parseEval(mytext, &env); + snprintf(mytext, MAX_LENGTH, "R:%d", obj.number); + selected_token = 0; + //strcpy(mytext, HAHA); updateText(); - if(1) - return; - - /* - bool overflow = false; //Overflow flag - // Convert operands to numbers - fixed lhs = str_to_fixed(num1, &overflow); - fixed rhs = str_to_fixed(num2, &overflow); - fixed result = 0; - //Calculate the result - switch(operator){ - case 0: - result = fixed_add(lhs, rhs, &overflow); - break; - case 1: - result = fixed_subt(lhs, rhs, &overflow); - break; - case 2: - result = fixed_mult(lhs, rhs, &overflow); - break; - case 3: - result = fixed_div(lhs, rhs); - break; - case 4: - result = fixed_pow(lhs, fixed_to_int(rhs), &overflow); //Exponent must be an int - break; - default: - result = 0; - } - - APP_LOG(APP_LOG_LEVEL_DEBUG, "num1: %d num2: %d result: %d", lhs, rhs, result); - - //Reset operands, operator_entered and entering_decimal - *num1 = 0; - *num2 = 0; - operator_entered = false; - - if(overflow){ - text_layer_set_text(s_input_text_layer, "Overflow Error"); //Display message on overflow - } - else{ - fixed_repr(result, result_text, MAX_LENGTH); //Convert result to string - text_layer_set_text(s_input_text_layer, result_text); //Display result - strcpy(num1, result_text); //Copy result into num1 - num1_is_ans = true; - } - */ } // Button press handler diff --git a/src/calc.h b/src/calc.h index e89c215..6b4c1cc 100644 --- a/src/calc.h +++ b/src/calc.h @@ -9,6 +9,8 @@ Window *s_window; TextLayer *s_input_text_layer; +const char *HAHA = "STONKS"; + char mytext[SMAX_LENGTH] = ""; char temptext[SMAX_LENGTH] = ""; diff --git a/src/pebblisp.c b/src/pebblisp.c index 20898e4..1bdda30 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -233,9 +233,10 @@ Object parseEval(const char *input, struct Environment *env) { struct Slice *tokens = tokenize(input); struct Slice *debug = tokens; +#ifdef STANDALONE if(debug) { while(debug->text) { - char tok[10]; + char tok[MAX_TOK_LEN]; copySlice(tok, debug); // printf("'%s', ", tok); debug++; @@ -245,6 +246,7 @@ Object parseEval(const char *input, struct Environment *env) // printf("parse error\n"); } // printf("parseEval() parse()\n"); +#endif Object parsed = parse(tokens).obj; return eval(&parsed, env); } diff --git a/src/pebblisp.h b/src/pebblisp.h index 4c25cd1..da97a6c 100644 --- a/src/pebblisp.h +++ b/src/pebblisp.h @@ -3,9 +3,9 @@ // #define STANDALONE -#define MAX_TOK_LEN 6 -#define MAX_TOK_CNT 128 -#define MAX_ENV_ELM 50 +#define MAX_TOK_LEN 3 +#define MAX_TOK_CNT 7 // 128 +#define MAX_ENV_ELM 3 // 50 // static const char* tokenFail = "Missing ')'\n";