from pygments.style import Style
from pygments.token import (
  Keyword,
  Name,
  Punctuation,
  Comment,
  String,
  Literal,
  Text,
  Error,
  Number,
  Operator,
  Generic )

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def pygments_style(colors):

  class PygmentsStyle(Style):
    background_color = colors.dynamic.back_alt
    highlight_color = colors.active.back_alt

    default_style = ''

    styles = {
      Text : colors.dynamic.fore_alt,
      Text.Whitespace : colors.gray.high,
      Punctuation : colors.cyan.low,
      Comment : f'italic {colors.gray.high}',
      Comment.Hashbang : f'italic {colors.gray.high}',
      Comment.Multiline : f'italic {colors.gray.high}',
      Comment.Preproc : colors.orange.low,
      Comment.PreprocFile : f'italic {colors.gray.high}',
      Comment.Single : f'italic {colors.gray.high}',
      Comment.Special : f'italic {colors.gray.high}',
      Generic : colors.orange.low,
      Generic.Deleted : colors.red.low,
      Generic.Emph : 'italic',
      Generic.Error : f'border:{colors.red.low}',
      Generic.Heading : f'bold {colors.blue.low}',
      Generic.Inserted : colors.green.mid,
      Generic.Output : colors.gray.low,
      Generic.Prompt : f'{colors.blue.low}',
      Generic.Strong : 'bold',
      Generic.Subheading : f'{colors.magenta.mid}',
      Generic.Traceback : colors.green.low,
      Keyword : colors.magenta.mid,
      Keyword.Constant : f'{colors.orange.low}',
      Keyword.Declaration : f'{colors.orange.low}',
      Keyword.Namespace : f'{colors.magenta.mid}',
      Keyword.Pseudo : f'{colors.orange.low}',
      Keyword.Reserved : f'{colors.orange.low}',
      Keyword.Type : f'bold {colors.orange.mid}',
      Operator : colors.gray.mid,
      Operator.Word : colors.magenta.low,
      Name : colors.gray.low,
      Name.Namespace : colors.gray.low,
      Name.Tag : f'{colors.red.mid}',
      Name.Label : colors.orange.low,
      Name.Other : colors.orange.low,
      Name.Attribute : colors.orange.low,
      Name.Property : colors.orange.low,
      Name.Builtin : colors.blue.low,
      Name.Builtin.Pseudo : colors.orange.low,
      Name.Constant : colors.orange.low,
      Name.Class : f'bold {colors.orange.mid}',
      Name.Decorator : colors.magenta.mid,
      Name.Entity : f'{colors.magenta.mid}',
      Name.Exception : f'{colors.red.mid}',
      Name.Function : colors.blue.low,
      Name.Function.Magic : colors.blue.low,
      Name.Variable : colors.magenta.mid,
      Name.Variable.Class : colors.red.mid,
      Name.Variable.Global : colors.red.mid,
      Name.Variable.Instance : colors.red.mid,
      Name.Variable.Magic : colors.red.mid,
      # NOTE: custom name token
      Name.External : f'{colors.blue.low} underline',
      Literal : colors.orange.low,
      Literal.Number : colors.orange.low,
      Literal.Number.Bin : colors.orange.low,
      Literal.Number.Float : colors.orange.low,
      Literal.Number.Hex : colors.orange.low,
      Literal.Number.Integer : colors.orange.low,
      Literal.Number.Integer.Long : colors.orange.low,
      Literal.Number.Oct : colors.orange.low,
      Literal.String : colors.green.mid,
      Literal.String.Affix : colors.green.mid,
      Literal.String.Backtick : colors.green.mid,
      Literal.String.Char : colors.green.mid,
      Literal.String.Delimiter : colors.green.mid,
      Literal.String.Doc : colors.green.mid,
      Literal.String.Double : colors.green.mid,
      Literal.String.Escape : colors.cyan.mid,
      Literal.String.Heredoc : colors.green.mid,
      Literal.String.Interpol : colors.red.low,
      Literal.String.Other : colors.green.mid,
      Literal.String.Regex : colors.cyan.mid,
      Literal.String.Single : colors.green.mid,
      Literal.String.Symbol : colors.green.mid,
      Literal.Scalar : colors.green.mid,
      Literal.Scalar.Plain : colors.green.mid }

  return PygmentsStyle
