packages feed

isocline 1.0.7 → 1.0.8

raw patch · 4 files changed

+42/−39 lines, 4 files

Files

isocline.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.6. -- -- see: https://github.com/sol/hpack  name:           isocline-version:        1.0.7+version:        1.0.8 synopsis:       A portable alternative to GNU Readline description:    ![logo](https://raw.githubusercontent.com/daanx/isocline/main/doc/isocline-inline.svg) A Haskell wrapper around the [Isocline C library](https://github.com/daanx/isocline#readme) which can provide an alternative to GNU Readline. (The Isocline library is included whole and there are no runtime dependencies).                 Please see the [readme](https://github.com/daanx/isocline/haskell#readme) on GitHub for more information.
src/bbcode.c view
@@ -763,6 +763,7 @@ }  ic_private void bbcode_append( bbcode_t* bb, const char* s, stringbuf_t* out, attrbuf_t* attr_out ) {+  if (bb == NULL || s == NULL) return;   attr_t attr = attr_none();   const ssize_t base = bb->tags_nesting; // base; will not be popped   ssize_t i = 0;@@ -802,7 +803,7 @@ }  ic_private void bbcode_print( bbcode_t* bb, const char* s ) {-  if (bb->out == NULL || bb->out_attrs == NULL) return;+  if (bb->out == NULL || bb->out_attrs == NULL || s == NULL) return;   assert(sbuf_len(bb->out) == 0 && attrbuf_len(bb->out_attrs) == 0);   bbcode_append( bb, s, bb->out, bb->out_attrs );   term_write_formatted( bb->term, sbuf_string(bb->out), attrbuf_attrs(bb->out_attrs,sbuf_len(bb->out)) );@@ -816,7 +817,7 @@ }  ic_private void bbcode_vprintf( bbcode_t* bb, const char* fmt, va_list args  ) {-  if (bb->vout == NULL) return;+  if (bb->vout == NULL || fmt == NULL) return;   assert(sbuf_len(bb->vout) == 0);   sbuf_append_vprintf(bb->vout,fmt,args);   bbcode_print(bb, sbuf_string(bb->vout));@@ -831,7 +832,7 @@ }  ic_private ssize_t bbcode_column_width( bbcode_t* bb, const char* s ) {-  if (s==0 || s[0] == 0) return 0;+  if (s==NULL || s[0] == 0) return 0;   if (bb->vout == NULL) { return str_column_width(s); }   assert(sbuf_len(bb->vout) == 0);    bbcode_append( bb, s, bb->vout, NULL);
src/term.c view
@@ -348,42 +348,43 @@   if (getenv("NO_COLOR") != NULL) {     term->nocolor = true;   }--  // detect color palette-  // COLORTERM takes precedence-  const char* colorterm = getenv("COLORTERM");  -  const char* eterm = getenv("TERM");    -  if (ic_contains(colorterm,"24bit") || ic_contains(colorterm,"truecolor") || ic_contains(colorterm,"direct")) { -    term->palette = ANSIRGB; -  }-  else if (ic_contains(colorterm,"8bit") || ic_contains(colorterm,"256color")) { term->palette = ANSI256; } -  else if (ic_contains(colorterm,"4bit") || ic_contains(colorterm,"16color"))  { term->palette = ANSI16; }-  else if (ic_contains(colorterm,"3bit") || ic_contains(colorterm,"8color"))   { term->palette = ANSI8; }-  else if (ic_contains(colorterm,"1bit") || ic_contains(colorterm,"nocolor") || ic_contains(colorterm,"monochrome")) { -    term->palette = MONOCHROME; -  }-  // otherwise check for some specific terminals-  else if (getenv("WT_SESSION") != NULL) { term->palette = ANSIRGB; } // Windows terminal-  else if (getenv("ITERM_SESSION_ID") != NULL) { term->palette = ANSIRGB; } // iTerm2 terminal-  else if (getenv("VSCODE_PID") != NULL) { term->palette = ANSIRGB; } // vscode terminal-  else {-    // and otherwise fall back to checking TERM-    if (ic_contains(eterm,"truecolor") || ic_contains(eterm,"direct") || ic_contains(colorterm,"24bit")) {-      term->palette = ANSIRGB;-    }-    else if (ic_contains(eterm,"alacritty") || ic_contains(eterm,"kitty")) {-      term->palette = ANSIRGB;+  if (!term->nocolor) {+    // detect color palette+    // COLORTERM takes precedence+    const char* colorterm = getenv("COLORTERM");  +    const char* eterm = getenv("TERM");    +    if (ic_contains(colorterm,"24bit") || ic_contains(colorterm,"truecolor") || ic_contains(colorterm,"direct")) { +      term->palette = ANSIRGB;      }-    else if (ic_contains(eterm,"256color") || ic_contains(eterm,"gnome")) { -      term->palette = ANSI256;-    }  -    else if (ic_contains(eterm,"16color")){ term->palette = ANSI16; }-    else if (ic_contains(eterm,"8color")) { term->palette = ANSI8; }-    else if (ic_contains(eterm,"monochrome") || ic_contains(eterm,"nocolor") || ic_contains(eterm,"dumb")) { +    else if (ic_contains(colorterm,"8bit") || ic_contains(colorterm,"256color")) { term->palette = ANSI256; } +    else if (ic_contains(colorterm,"4bit") || ic_contains(colorterm,"16color"))  { term->palette = ANSI16; }+    else if (ic_contains(colorterm,"3bit") || ic_contains(colorterm,"8color"))   { term->palette = ANSI8; }+    else if (ic_contains(colorterm,"1bit") || ic_contains(colorterm,"nocolor") || ic_contains(colorterm,"monochrome")) {        term->palette = MONOCHROME;      }+    // otherwise check for some specific terminals+    else if (getenv("WT_SESSION") != NULL) { term->palette = ANSIRGB; } // Windows terminal+    else if (getenv("ITERM_SESSION_ID") != NULL) { term->palette = ANSIRGB; } // iTerm2 terminal+    else if (getenv("VSCODE_PID") != NULL) { term->palette = ANSIRGB; } // vscode terminal+    else {+      // and otherwise fall back to checking TERM+      if (ic_contains(eterm,"truecolor") || ic_contains(eterm,"direct") || ic_contains(colorterm,"24bit")) {+        term->palette = ANSIRGB;+      }+      else if (ic_contains(eterm,"alacritty") || ic_contains(eterm,"kitty")) {+        term->palette = ANSIRGB;+      }+      else if (ic_contains(eterm,"256color") || ic_contains(eterm,"gnome")) { +        term->palette = ANSI256;+      }  +      else if (ic_contains(eterm,"16color")){ term->palette = ANSI16; }+      else if (ic_contains(eterm,"8color")) { term->palette = ANSI8; }+      else if (ic_contains(eterm,"monochrome") || ic_contains(eterm,"nocolor") || ic_contains(eterm,"dumb")) { +        term->palette = MONOCHROME; +      }+    }+    debug_msg("term: color-bits: %d (COLORTERM=%s, TERM=%s)\n", term_get_color_bits(term), colorterm, eterm);   }-  debug_msg("term: color-bits: %d (COLORTERM=%s, TERM=%s)\n", term_get_color_bits(term), colorterm, eterm);      // read COLUMS/LINES from the environment for a better initial guess.   const char* env_columns = getenv("COLUMNS");
test/Example.hs view
@@ -57,8 +57,9 @@               [ ("D — (x) => x",       "(x) => x")
               , ("Haskell — \\x -> x", "\\x -> x")
               , ("Idris — \\x => x",   "\\x => x")
-              , ("Koka — fn(x){ x }",  "fn(x){ x }")
-              , ("Ocaml — fun x -> x", "fun x -> x")]
+              , ("Ocaml — fun x -> x", "fun x -> x")
+              , ("Koka — fn(x) x",  "fn(x) x")
+              , ("Rust — |x| x", "|x| x") ]
          else []) 
        ++
        -- add many hello isocline completions; we should generate these lazily!