package grace
A fancy diagnostics library that allows your compilers to exit with grace
Install
Dune Dependency
Authors
Maintainers
Sources
grace-0.2.0.tbz
sha256=821df54882c9253eac69f47bcf3a71ffdc61c77fdae42587c32aada5b56cfeae
sha512=007afa83251da3ddecd874e120ea89dce0253c387a64a5fece69069d3486ec5eb6c82d6bf0febaf23dd322bd9eaadc2f7882e33f05a2e1fa18a41294e7dc3ba1
doc/src/grace.ansi_renderer/config.ml.html
Source file config.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
open! Import open Diagnostic module Style_sheet = struct type style = Fmt.style list let not_color : Fmt.style -> bool = function | `None | `Bold | `Faint | `Italic | `Underline | `Reverse -> true | _ -> false ;; let no_color_style = List.filter ~f:not_color type t = { header_bug : style ; header_error : style ; header_warning : style ; header_note : style ; header_help : style ; header_message : style ; primary_label_bug : style ; primary_label_error : style ; primary_label_warning : style ; primary_label_note : style ; primary_label_help : style ; secondary_label : style ; line_number : style ; source_border : style ; note_bullet : style } let map t ~f = { header_bug = f t.header_bug ; header_error = f t.header_error ; header_warning = f t.header_warning ; header_note = f t.header_note ; header_help = f t.header_help ; header_message = f t.header_message ; primary_label_bug = f t.primary_label_bug ; primary_label_error = f t.primary_label_error ; primary_label_warning = f t.primary_label_warning ; primary_label_note = f t.primary_label_note ; primary_label_help = f t.primary_label_help ; secondary_label = f t.secondary_label ; line_number = f t.line_number ; source_border = f t.source_border ; note_bullet = f t.note_bullet } ;; let no_color t = map t ~f:no_color_style let default = let header color = [ `Bold; `Fg (`Hi color) ] in let primary_label color = [ `Fg color ] in { header_bug = header `Red ; header_error = header `Red ; header_warning = header `Yellow ; header_note = header `Green ; header_help = header `Cyan ; header_message = [ `Bold ] ; primary_label_bug = primary_label `Red ; primary_label_error = primary_label `Red ; primary_label_warning = primary_label `Yellow ; primary_label_note = primary_label `Green ; primary_label_help = primary_label `Cyan ; secondary_label = [ `Fg `Cyan ] ; line_number = [ `Fg `Cyan ] ; source_border = [ `Fg `Cyan ] ; note_bullet = [ `Fg `Cyan ] } ;; let header config (severity : Severity.t) = match severity with | Bug -> config.header_bug | Error -> config.header_error | Warning -> config.header_warning | Note -> config.header_note | Help -> config.header_help ;; let label config (priority : Priority.t) (severity : Severity.t) = match priority, severity with | Primary, Bug -> config.primary_label_bug | Primary, Error -> config.primary_label_error | Primary, Warning -> config.primary_label_warning | Primary, Note -> config.primary_label_note | Primary, Help -> config.primary_label_help | Secondary, _ -> config.secondary_label ;; end module Chars = struct type t = { snippet_start : string ; source_border_left : string ; source_border_left_break : string ; note_bullet : string ; single_primary_caret : string ; single_secondary_caret : string ; multi_primary_caret_start : string ; multi_primary_caret_end : string ; multi_secondary_caret_start : string ; multi_secondary_caret_end : string ; multi_top_left : string ; multi_top : string ; multi_bottom_left : string ; multi_bottom : string ; multi_left : string ; pointer_left : string } let ascii = { snippet_start = "-->" ; source_border_left = "|" ; source_border_left_break = "." ; note_bullet = "=" ; single_primary_caret = "^" ; single_secondary_caret = "-" ; multi_primary_caret_start = "^" ; multi_primary_caret_end = "^" ; multi_secondary_caret_start = "\'" ; multi_secondary_caret_end = "\'" ; multi_top_left = "/" ; multi_top = "-" ; multi_bottom_left = "\\" ; multi_bottom = "-" ; multi_left = "|" ; pointer_left = "|" } ;; let unicode = { snippet_start = "┌─" ; source_border_left = "│" ; source_border_left_break = "·" ; note_bullet = "=" ; single_primary_caret = "^" ; single_secondary_caret = "-" ; multi_primary_caret_start = "^" ; multi_primary_caret_end = "^" ; multi_secondary_caret_start = "\'" ; multi_secondary_caret_end = "\'" ; multi_top_left = "╭" ; multi_top = "─" ; multi_bottom_left = "╰" ; multi_bottom = "─" ; multi_left = "│" ; pointer_left = "│" } ;; end type t = { chars : Chars.t ; styles : Style_sheet.t ; use_ansi : bool } let no_color = match Sys.getenv "NO_COLOR" with | None | Some "" -> false | _ -> true ;; let is_rich_term = match Sys.getenv "TERM" with | None | Some "" | Some "dumb" -> false | _ -> true ;; let style_renderer t = if t.use_ansi then `Ansi_tty else `None let default = let styles = if no_color then Style_sheet.(no_color default) else Style_sheet.default in { chars = Chars.unicode; styles; use_ansi = is_rich_term } ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>