<commit_before>// @(#)root/editline:$Id$
// Author: <NAME>, 2009

/*************************************************************************
 * Copyright (C) 1995-2009, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef INCLUDE_TTERMMANIP_H
#define INCLUDE_TTERMMANIP_H

#include <map>
#include <cstring>
#include <stdio.h>

// setupterm must be called before TTermManip can be created!
class TTermManip {
public:
   TTermManip();
   ~TTermManip() { ResetTerm(); }

   bool SetColor(unsigned char r, unsigned char g, unsigned char b);

   void
   StartUnderline() {
      if (!fCurrentlyUnderlined) {
         WriteTerm(fStartUnderline);
         fCurrentlyUnderlined = true;
      }
   }


   void
   StopUnderline() {
      if (fCurrentlyUnderlined) {
         WriteTerm(fStopUnderline);
         fCurrentlyUnderlined = false;
      }
   }


   bool ResetTerm();
   void SetDefaultColor();

private:
   class Color {
   public:
      Color(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0):
         fR((r* 1001) / 256),
         fG((g* 1001) / 256),
         fB((b* 1001) / 256) {
         // Re-normalize RGB components from 0 to 255 to 0 to 1000
      }


      bool
      operator <(const Color& c) const {
         return fR < c.fR
                || (fR == c.fR && (fG < c.fG
                                   || (fG == c.fG && fB < c.fB)));
      }


      unsigned char fR, fG, fB;
   };

   char* GetTermStr(const char* cap);

   bool WriteTerm(char* termstr);

   bool WriteTerm(char* termstr, int i);<commit_msg>Color rgb values are commonly >255. Fixes colors on terminals supporting initc, e.g. xterm-256color<commit_after>// @(#)root/editline:$Id$
// Author: <NAME>, 2009

/*************************************************************************
 * Copyright (C) 1995-2009, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef INCLUDE_TTERMMANIP_H
#define INCLUDE_TTERMMANIP_H

#include <map>
#include <cstring>
#include <stdio.h>

// setupterm must be called before TTermManip can be created!
class TTermManip {
public:
   TTermManip();
   ~TTermManip() { ResetTerm(); }

   bool SetColor(unsigned char r, unsigned char g, unsigned char b);

   void
   StartUnderline() {
      if (!fCurrentlyUnderlined) {
         WriteTerm(fStartUnderline);
         fCurrentlyUnderlined = true;
      }
   }


   void
   StopUnderline() {
      if (fCurrentlyUnderlined) {
         WriteTerm(fStopUnderline);
         fCurrentlyUnderlined = false;
      }
   }


   bool ResetTerm();
   void SetDefaultColor();

private:
   class Color {
   public:
      Color(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0):
         fR((r* 1001) / 256),
         fG((g* 1001) / 256),
         fB((b* 1001) / 256) {
         // Re-normalize RGB components from 0 to 255 to 0 to 1000
      }


      bool
      operator <(const Color& c) const {
         return fR < c.fR
                || (fR == c.fR && (fG < c.fG
                                   || (fG == c.fG && fB < c.fB)));
      }


      int fR, fG, fB;
   };

   char* GetTermStr(const char* cap);

   bool WriteTerm(char* termstr);

   bool WriteTerm(char* termstr, int i);
{'fraction_non_alphanumeric': 0.1803699897225077, 'fraction_numerical': 0.024665981500513873, 'mean_word_length': 1.8987341772151898, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4487301', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1088, 'n_words': 311}