Class: RBT::ColourizeParser

Inherits:
Base show all
Defined in:
lib/rbt/misc/colourize_parser.rb

Overview

RBT::ColourizeParser

Constant Summary

Constants inherited from LeanPrototype

LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #is_this_program_included?, #make_command?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #run_make_then_make_install, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget

Methods inherited from LeanPrototype

#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #available_programs?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_arguments, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_meson_installed?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #is_this_program_included?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #n_programs_are_available?, #n_programs_available?, #namespace?, #no_directory_exists_at, #no_directory_was_found_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #opnn, #otomato, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_the_first_commandline_argument, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_name, #return_program_name_for_gobolinux_systems, #return_program_name_via_program_information, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #rpn, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_colours, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no

Constructor Details

#initialize(i = nil, run_already = true) ⇒ ColourizeParser

#

initialize

#


27
28
29
30
31
32
33
34
# File 'lib/rbt/misc/colourize_parser.rb', line 27

def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_line(i) if i
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

RBT::ColourizeParser[]

#


879
880
881
# File 'lib/rbt/misc/colourize_parser.rb', line 879

def self.[](i = ARGV)
  new(i)
end

.parse_this_line(line) ⇒ Object

#

RBT::ColourizeParser.parse_this_line

#


865
866
867
# File 'lib/rbt/misc/colourize_parser.rb', line 865

def self.parse_this_line(line)
  new(line).line?
end

Instance Method Details

#colour_for_found(i) ⇒ Object

#

colour_for_found

This method will colourize the word “found”. That word is used in particular for checks made in some cmake-based projects, such as the KDE project.

#


840
841
842
# File 'lib/rbt/misc/colourize_parser.rb', line 840

def colour_for_found(i)
  darkorchid(i)
end

#colour_for_warnings_and_errors(i) ⇒ Object Also known as: colour_for_warning_and_errors

#

colour_for_warnings_and_errors

#


847
848
849
# File 'lib/rbt/misc/colourize_parser.rb', line 847

def colour_for_warnings_and_errors(i)
  crimson(i)
end

#line?Boolean Also known as: input?

#

line?

#

Returns:

  • (Boolean)


52
53
54
# File 'lib/rbt/misc/colourize_parser.rb', line 52

def line?
  @line
end

#parse_missing_dependency(i) ⇒ Object

#

parse_missing_dependency

This method will try to colourize a String such as:

meson.build:38:0: ERROR:  Dependency "telepathy-glib" not found, tried pkgconfig and cmake
#


857
858
859
860
# File 'lib/rbt/misc/colourize_parser.rb', line 857

def parse_missing_dependency(i)
  regex_to_use = /ERROR:\s+Dependency "(.+)" not found/
  i.sub(regex_to_use, crimson('\1'))
end

#resetObject

#

reset (reset tag)

#


39
40
41
42
43
44
45
46
47
# File 'lib/rbt/misc/colourize_parser.rb', line 39

def reset
  super()
  infer_the_namespace
  enable_colours
  # ======================================================================= #
  # === @line
  # ======================================================================= #
  @line = ''.dup
end

#runObject

#

run (run tag)

#


872
873
874
# File 'lib/rbt/misc/colourize_parser.rb', line 872

def run
  # Empty placeholder.
end

#sanitize_lineObject

#

sanitize_line

We must be careful in this method, as “line.squeeze!()” may fail due to an ArgumentError.

#


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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
# File 'lib/rbt/misc/colourize_parser.rb', line 73

def sanitize_line
  begin
    stripped_line = @line.strip
  rescue ArgumentError, Encoding::CompatibilityError => error
    pp error if is_on_roebe?
    stripped_line = @line.to_s.dup # Work on a copy nonetheless.
  end
  stripped_line = stripped_line.dup if stripped_line and stripped_line.frozen?

  _paleturquoise = ALL_COLOUR_METHODS.paleturquoise
  # ======================================================================= #
  # === cmake colourizing                                       (cmake tag)
  #
  # Cmake does some colourizing - we will try to re-create this here,
  # starting with 'Building CXX object'.
  # ======================================================================= #
  if @line.include?('Building CXX object')        or
     @line.include?('Linking C shared library')   or
     @line.include?('] Copying llvm')             or
     @line.include?('] Creating export file')     or
     @line.include?('] [FLEX]')                   or
     @line.include?('] Linking target ')          or
     @line.include?('] Generating')               or
     @line.include?('] Running moc')              or
     @line.include?('] Merging translations for') or
     @line.include?('] Making')                   or
     @line.include?('] Updated:')                 or
     @line.include?('] actions for')              or
     @line.include?('] Validating for')           or # Example: "[ 25%] Validating SVG"
     @line.include?('] Built target')             or
     @line.include?('Built target ')              or # Example: "[ 8%] Built target aom_pc"
     @line.include?('] Copying ')                 or # Example: "[ 23%] Copying clang's arm_mve.h..."
     @line.include?('] Gzipping ')                or
     @line.include?('] Generate bindings ')       or # e. g. for "[ 39%] Generate bindings (WebCoreBindings)"
     @line.include?('] Completed ')               or
     @line.include?('] Linking')                  or
     @line.include?('] Compiling')                or
     @line.include?('] Creating')                 or
     @line.include?('] Generate files for')       or
     @line.include?('] Processing ')              or
     @line.include?('] mo-update: ')              or
     @line.include?('] mo-update [')              or
     @line.include?('] Updating ')                or
     @line.include?('] Building ')                or
     @line.include?('] Preparing ')               or
     @line.include?('] Building C object')        or
     @line.include?('] Running AUTOMOC ')         or
     @line.include?('] Built target')             or
     @line.include?('] Linking C executable')     or
     @line.include?('] Compiling C object')       or
     @line.include?('] Compiling C++ object')     or
     @line.include?('] Running rcc ')             or
     @line.include?('] Compiling Vala source')    or
     @line.include?('] Checking the ')            or
     @line.include?('] Linking static target')    or
     @line.include?('] Linking CXX shared')       or
     @line.include?('] Linking CXX static')       or
     @line.include?('] Linking CXX executable')   or
     @line.include?('] Creating library symlink') or
     @line.include?('] Linking C static library') or
     @line.include?('] Linking C shared')         or
     @line.include?('] Installing files.')        or
    (@line.include?('] Automatic ')               and
     @line.include?(' for '))                     or
    (@line.include?('] Compiling ')               and
     @line.include?('.po'))
    @line = limegreen(@line)
  # ======================================================================= #
  # === Colourize cd-related actions (cd stands for change directory)
  #
  # The Qt build-system makes use of the following line:
  #
  #   cd qtsensors/ &&
  #
  # ======================================================================= #
  elsif @line.start_with?('cd ') and @line.include?(' && ')
    @line = orangered(@line)
  # ======================================================================= #
  # === Checking for something
  #
  # This entry point is for Strings such as:
  #   -- Check for working C compiler: /System/Index/bin/cc
  # ======================================================================= #
  elsif @line.start_with?('-- Check for working C')
    if @line.end_with? ' -- works'
      @line.sub!(/(^.+)( -- works$)/, peru('\1')+orange('\2'))
    else
      @line = peru(@line)
    end
  # ======================================================================= #
  # === "Leaving directory" and "Entering directory"
  #
  # We handle both values in the same code, largely due to consistency.
  # ======================================================================= #
  elsif @line.include?('Leaving directory') or
        @line.include?('Entering directory')
    # ===================================================================== #
    # Match against "make[1]: Leaving directory '/Depot/Temp/xz-5.2.3/po'".
    # ===================================================================== #
    leaving_or_entering = 'Leaving' # <- default value.
    case @line
    # ===================================================================== #
    # === Leaving directory
    # ===================================================================== #
    when /Leaving directory/
      use_this_regex = /Leaving directory '(.+)'/
    # ===================================================================== #
    # === Entering directory
    # ===================================================================== #
    when /Entering directory/
      use_this_regex = /Entering directory '(.+)'/
      leaving_or_entering = 'Entering'
    end
    @line.sub!(use_this_regex,
      slategray("#{leaving_or_entering} directory '")+
      colourize_directory_for_system_results('\\1')+
      slategray("'")
    ) 
  # ======================================================================= #
  # === -- Checking for module 'libavformat'
  # ======================================================================= # 
  elsif @line.include?('-- Checking for module ') or
        @line.include?('-- Checking for modules ') 
    # ===================================================================== #
    # For the regex, see:
    #   http://rubular.com/r/FQ0kx0tH9n
    # ===================================================================== #
    use_this_regex = /(-- Checking for modules? ')(.+)'$/
    @line.sub!(use_this_regex,
      '\\1'+orchid('\\2')+"'"
    )
  # ======================================================================= #
  # === mkdir -p
  #
  # We will only colourize here if there are at the least two "'" tokens.
  # This should colourize lines such as:
  #
  #   /System/Index/bin/mkdir -p '/usr/bin'
  #
  # ======================================================================= #
  elsif @line.include?('mkdir -p') and (@line.count("'") > 1)
    use_this_regex = /^(\s+.+mkdir -p ')(.+)(')/ # 3 internal regex-matches.
    @line.sub!(
      use_this_regex,
      lightseagreen('\\1')+
      lightslategray('\\2')+
      lightseagreen('\\3')
    )
  # ======================================================================= #
  # === -- Build files have been written to:
  # ======================================================================= # 
  elsif @line.include?('-- Build files have been written to: ') or
        @line.include?('-- Configuring done') or # -- Configuring done
        @line.include?('-- Generating done')    # -- Generating done
    if @line.include?('-- Build files have been')
      regex_to_use = /(-- Build files have been written to: )(.+)/
      @line.sub!(
        regex_to_use,
        lightgreen('\\1')+
        lightslategray('\\2')
      )
    else
      @line = lightgreen(@line) # <-- Sync with the above ^^^ if-clause.
    end
  # ======================================================================= #
  # === clang
  # ======================================================================= #
  elsif @line.start_with?('clang') and
        @line.include?('warning: argument unused during compilation:')
    use_this_regex = /(clang.+:)( warning: argument unused during compilation:.+)/
    @line.sub!(use_this_regex, '\\1'+rosybrown('\\2'))
  # ======================================================================= #
  # === GEN and others
  #
  # Note that most of these entries start with 2 ' ' tokens, but some
  # also use 4 ' ' tokens. (This refers to leading spaces.)
  # ======================================================================= #
  elsif @line.start_with?(
    '  GEN    ',
    '    GEN ',
    '  GUILEC ',
    'wrote `',
    '  CC   ',
    '  BUNZIP2 ',
    '  XS ',
    '  BS ',
    ' BLIB  ', # This weird leading mini-indent is correct, though (Sep 2019).
    ' CHMOD  ',
    '  CP ',
    '  CCLD ',
    '  A11Y ',
    '  NASM ',
    '  HUGE ',
    '    CC ',
    '  AR    ',
    '    [CC]     ',
    '  HOSTCC',
    '  DOC',
    '  VDSO2C',
    '  SYSHDR',
    '  WRAP',
    '  GISCAN',
    '    [LN]     ',
    '    [STRIP] ',
    '    [PY] ',
    '  SED','   [HEADERS] ','  SPLIT','    [GENERATE] ',
    '  CCAS ',
    '    [TEST]    ',
    '  LN_S ',
    '  GISCAN ',
    '  GICOMP ',
    '  PPFC ',
    '  FCLD ',
    '  CPPAS ',
    '  LTLINK ',
    '  AR ',
    '  LD ',
    '  RANLIB ',
    '  MSGFMT ',
    '  ITMRG ',
    '   INSTALL ',
    '    SUBDIR',
    '  GENERATE',
    '  UIC',
    '  MOC ',
    '  HOSTLD',
    '  SHIPPED',
    '  PC ',
    '    [INSTALL]     ',
    '  LINK',
    '  CHK ',
    '  DESCEND ',
    '  CALL ',
    '  VERT ',
    '  FRAG ',
    '  AS ',
    '  AS [M] ',
    '  CC [M] ',
    '  VDSO ',
    '  LDS ',
    '    [DEP] ',
    '    [CC] ',
    '    [SED] ',
    '    [DOXY] ',
    '    [CREATE] ',
    '    [CXX] ',
    '    [AR] ',
    '    [AS] ',
    '    [LD] ',
    '    [LD]     ',
    '    [INSTALL] ',
    '    AR ',
    '    RANLIB ',
    '    C++ ',
    '    LINK ',
    '    BUILTIN ',
    '    MSGFMT ',
    '    LN/CP ',
    '   (deps)      ',
    '    OBJCOPY ',
    '  OBJCOPY ',
    '    CXX',
    '    YACC',
    '    SWIG',
    '    YACC',
    '  CXX ',
    '  CXXLD '
  )
    @line = darkseagreen(@line) # Colourize green.
  # ======================================================================= #
  # === R-like installation procedures, starting with the String "installing "
  #     but it will also be used for other instances of the word
  #     "installing".
  # ======================================================================= #
  elsif (@line.start_with?('installing ') and
        (@line =~ /^installing .+ \.\.\./)) or
        (@line.start_with?('Installing ') and
         @line.include?(' to ')) or
        (@line.start_with?('Making directory /')) or
        (@line.start_with?('installing  ') and
         @line.include?(' in /')) or
        (@line.include?('Installing ') and @line.include?(' as '))
    @line = darkseagreen(@line) # Colourize green; sync with the ^^^ above.
  # ======================================================================= #
  # === *new something
  #
  # This is similar to the entry above but we will try the colour
  # skyblue.
  # ======================================================================= #
  elsif @line.start_with?(
    '    * new build flags',
    '    * new link flags',
    '    * new perl-specific parameters',
    '    * new prefix flags',
    '    * new script parameters',
    'Note: ',
    'Creating makefiles for ' # This too, so that the user knows about it.
    )
    @line = skyblue(@line) # Colourize green.
  # ======================================================================= #
  # === config.status
  # ======================================================================= #
  elsif @line.start_with?('config.status')
    @line = limegreen(@line)
  # ======================================================================= #
  # === "which seems to be undefined.  Please make sure it is defined"
  # ======================================================================= #
  elsif @line.start_with?('which seems to be undefined.  Please make sure it is defined')
    # ===================================================================== #
    # This entry point here is assumed to belong to a config.status
    # derived notification.
    # ===================================================================== #
    @line = limegreen('which seems to be undefined.  ')+
            crimson('Please make sure it is defined')
  end
  # ======================================================================= #
  # === Scanning dependencies of
  #
  # This is mostly for some cmake-related build systems.
  # ======================================================================= #
  if @line.start_with?('Scanning dependencies of ') or
     @line.start_with?('Generating MOC')
    @line = mediumaquamarine(@line)
  # ======================================================================= #
  # === Colourize lines that start with "sed -"
  # ======================================================================= #
  elsif @line.start_with?('sed -')
    @line = skyblue(@line)
  # ======================================================================= #
  # === Building package xyz
  # ======================================================================= #
  elsif @line.start_with?('Building package') or
        @line.start_with?('Installing package')
    @line = teal(@line)
  end
  # ======================================================================= #
  # === The Meson build system
  #
  # Ideally every meson-related entry point can be defined in the
  # if-clause below this comment.
  # ======================================================================= #
  if @line.include? 'The Meson build system'
    @line = orchid(@line)
  elsif @line.include?('meson.build') and @line.include?('ERROR:  Dependency') and
        @line.include?('not found')
    # ===================================================================== #
    # We have encountered a missing dependency. We will in particular
    # colourize that dependency in a ~red colour.
    # ===================================================================== #
    @line = parse_missing_dependency(@line)
  end
  # ======================================================================= #
  # Next, colourize gcc, g++ and clang specifically - only these
  # three words, in the same colour. First, gcc.
  # ======================================================================= #
  if @line.start_with?('gcc -')
    use_this_regex = /^(gcc)( -)/
    @line.sub!(use_this_regex, orange('\\1')+'\\2')
    if @line.include? '-std=gnu++'
      use_this_regex = /(.+)(-std=gnu\+\+\d{1,2})(.+)/ # See: http://rubular.com/r/Oqk5yfzMkT
      @line.sub!(use_this_regex, '\\1'+khaki('\\2')+'\\3')
    end
  # ======================================================================= #
  # === g++
  # ======================================================================= #
  elsif @line.start_with?('g++') or
       (@line.include?('g++') and @line.include?('-DHAVE'))
    use_this_regex = /^(g\+\+)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === clang
  # ======================================================================= #
  elsif @line.start_with?('clang')
    use_this_regex = /(clang-?\d?\.?\d?):/
    @line.sub!(use_this_regex, orange('\\1')+':')
  # ======================================================================= #
  # === strip:
  # ======================================================================= #
  elsif @line.start_with?('strip:')
    use_this_regex = /^(strip):/
    @line.sub!(use_this_regex, orange('\\1')+':')
  # ======================================================================= #
  # === ranlib
  # ======================================================================= #
  elsif @line.start_with?('ranlib')
    use_this_regex = /^(ranlib)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === chmod
  # ======================================================================= #
  elsif @line.start_with?('chmod')
    use_this_regex = /^(chmod)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === /bin/sh
  # ======================================================================= #
  elsif @line.start_with?('/bin/sh')
    @line = paleturquoise(@line)
  # ======================================================================= #
  # === configure: creating ./config.status
  # ======================================================================= #
  elsif @line.start_with?('configure: creating ./config.status')
    @line = salmon(@line)
  end
  @line = @line.dup if @line.frozen?
  # ======================================================================= #
  # === -fno-strict-overflow
  # ======================================================================= #
  if @line.include? '-fno-strict-overflow'
    @line.sub!(
      /(-?fno-?strict-?overflow)/, colour_for_warnings_and_errors('\\1')
    )
  # ======================================================================= #
  # === I/O warning : failed to load external entity
  # ======================================================================= #
  elsif @line.include? 'I/O warning : failed to load external entity'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === -- Configuring incomplete, errors occurred!
  # ======================================================================= #
  elsif @line.include? '-- Configuring incomplete, errors occurred!'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === ld: error: cannot find -l
  # ======================================================================= #
  elsif @line.include? 'ld: error: cannot find -l'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === git repository (or any of the parent directories): .git
  # ======================================================================= #
  elsif @line.include? 'fatal: not a'
    @line = colour_for_warnings_and_errors(@line)
  end
  # ======================================================================= #
  # === -Wno-error
  # ======================================================================= #
  if @line.include? '-Wno-error'
    @line.sub!(/(-?Wno-?error)/, colour_for_warnings_and_errors('\\1')+_paleturquoise)
  end
  # ======================================================================= #
  # === rm -f
  # ======================================================================= #
  if @line.start_with?('rm -f')
    @line.sub!(/^rm -f/, colour_for_warnings_and_errors('\\1'))
  end
  # ======================================================================= #
  # === make
  #
  # Colourize leading "make" instances.
  # ======================================================================= #
  if @line.include?('make') and
     @line.include?(':')
    use_this_regex = /^(make)(\[\d{1}\])(:)/ # See: http://rubular.com/r/ECr3ERniGs
    @line =~ use_this_regex
    @line.sub!(use_this_regex, lightseagreen('\\1')+lightsteelblue('\\2')+('\\3'))
  # ======================================================================= #
  # === make all-recursive
  # ======================================================================= #
  elsif @line.include?('make') and
        @line.include?('all-recursive')
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === make install-am
  # ======================================================================= #
  elsif @line.include?('make') and
        @line.include?('all-am') # This also covers install-am.
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === Making all in (or "Making install in")
  # ======================================================================= #
  elsif @line.include?('Making all in') or
        @line.include?('Making install in') or
        @line.include?('make  install-exec-hook')
    @line = lightseagreen(@line)
  end
  # ======================================================================= #
  # === make ("Nothing to be done for 'xyz'".)
  # ======================================================================= #
  if @line.include?('Nothing to be done for') and
     @line.include?('make')
    use_this_regex = /( Nothing to be done for ')(.+)'\./
    @line.sub!(
      use_this_regex,
      slategray('\\1')+cadetblue('\\2')+slategray("'.")
    )
  # ======================================================================= #
  # === 'installing' or '.gmo '
  #
  # Examples for what triggers the next line would be:
  #   installing sr.gmo link as /Programs/Coreutils/8.30/share/locale/sr/LC_TIME/coreutils.mo
  #   installing sv.gmo as /Programs/Coreutils/8.30/share/locale/sv/LC_MESSAGES/coreutils.mo
  # ======================================================================= #
  elsif (@line.include?('installing') and
         @line.include?('.gmo '))
    use_this_regex = /^(installing .{1,15}\.gmo .+)$/
    @line.sub!(use_this_regex, darkcyan('\\1'))
  # ======================================================================= #
  # === 'Nothing to be done for'
  # ======================================================================= #
  elsif @line.include?('Nothing to be done for')
    use_this_regex = /(Nothing to be done for)/
    @line.sub!(use_this_regex, darkcyan('\\1'))
  end
  # ======================================================================= #
  # === Colourize PROGRAMS entries, in combination with 'install:'
  # ======================================================================= #
  if @line.include?('install:') and
     @line.include?(programs_dir?)
     programs_dir = Regexp.quote(programs_dir?)
     use_this_regex = /(.+)(#{programs_dir}.+?\/\d{1,3}\.\d{1,3}\.\d{1,3})(.+)/ # See: http://rubular.com/r/CpflAmlajz
    @line.sub!(use_this_regex,
      '\\1'+colourize_directory_for_system_results('\\2')+'\\3')
  end
  # ======================================================================= #
  # === Handle Libtool next - we may have to put these entries into a
  #     new subsections altogether.
  # ======================================================================= #
  # === Handle 'libtool: compile:' entry points next
  # ======================================================================= #
  if @line.include?('libtool: compile:  gcc -')
    use_this_regex = /(gcc)( -)/
    @line.sub!(use_this_regex, orange('\\1')+'\\2')
  # ======================================================================= #
  # === libtool: compile:  gcc -
  # ======================================================================= #
  elsif @line.include?('libtool: compile:') 
    use_this_regex = /(libtool: compile:)/
    @line.sub!(use_this_regex, cadetblue('\\1'))
  # ======================================================================= #
  # === libtool: install: 
  # ======================================================================= #
  elsif @line.include?('libtool: install: ') or # === libtool: install:
        @line.include?('libtool: finish: ') or  # === libtool: finish:
        @line.include?('libtool: link: ')       # === libtool: link:
    @line = cadetblue(@line)
  # ======================================================================= #
  # === 'libtool: warning:' and ' seems to be moved'
  # ======================================================================= #
  elsif (@line.include?('libtool: warning: ') and
        @line.include?(' seems to be moved'))
    @line = colour_for_warning_and_errors(@line)
  # ======================================================================= #
  # === 'ERROR: Neither directory contains a build file meson.build.'
  # ======================================================================= #
  elsif @line.include?('ERROR: Neither directory contains a build file meson.build.')
    @line = colour_for_warning_and_errors(@line)
    opne 'An error will be shown next, in red colour (if colours are used).'
    opne 'To aid in debugging, the current '\
         'working directory is:'
    opne sdir("  #{return_pwd}")
  # ======================================================================= #
  # === Libtool .la files
  # ======================================================================= #
  elsif @line.include? ".la' "
    use_this_regex = /'(.+\.la)'/ # See: http://rubular.com/r/KU3tB8ImeD
    @line.sub!(use_this_regex, "'"+lightgreen('\\1')+"'")
  end
  # ======================================================================= #
  # === Cmake log file
  # ======================================================================= #
  if @line.include?('See also "') and
     @line.include?('CMake') and
     @line.include?('.log')
    use_this_regex = /(See also ")(.+\.log)(".)/
    @line.sub!(use_this_regex, '\\1'+navajowhite('\\2')+'\\3')
  end
  # ======================================================================= #
  # === General warnings and errors
  #
  # This entry point will colourize the whole line.
  #
  # Some programs may use their own escape-code here, such as
  # "cc1: warning", which will appear colourized. Since this may
  # interfere with the colourizing that we do, the RBT project
  # will completely remove this colourization before doing
  # its own colourization.
  #
  # It will also match to lines such as the following one:
  #   valacodecontext.c:241:2: warning: 'g_static_private_get' is deprecated: Use 'g_private_get' instead [-Wdeprecated-declarations]
  # ======================================================================= #
  if (@line.include?("make: *** No rule to make target 'install'.  Stop.")) or
     (@line.include?("make: *** No targets specified and no makefile found.  Stop")) or
     (@line.include?('libtool: warning: relinking')) or
     (@line.include?('-- The following REQUIRED packages have not been found:')) or
     (@line.include?('ImportWarning:') and (@line.include?('.py') )) or
     (@line.include?('  from') and @line.include?('import')) or
     (@line.include?('.c: At top level:')) or
     (@line.include?('.c:') and @line.include?('warning: ') and @line.include?('is deprecated')) or
     (@line.include?('.cpp: In member function')) or
     (@line.include?('.cpp: In lambda function')) or
     (@line.include?('   ^~~~~~~~~~~~~~~~~~~')) or
     (@line.include?('cc1:') and @line.include?('warning:')) or # <- colourize cc1-related warnings in general
     (@line.include?('cc1:') and @line.include?('note:')) or
     (@line.include?('.la: No such file or directory')) or
     (@line.include?('No ') and @line.include?(' localization of ') and @line.include?(' exists; using')) or
     (@line.include?('Compilation failed: ') and @line.include?('error')) or # <- For lines such as this: "Compilation failed: 1 error(s), 8 warning(s)"
     (@line.include?('ninja: build stopped: subcommand failed.')) or # <- For lines such as "ninja: build stopped: subcommand failed."
     (@line.include?('UnicodeEncodeError: ')) or # <- Meson had some Unicode-related error
     (@line.include?(': DeprecationWarning: ')) or
     (@line.include?('ResourceWarning: unclosed file')) or
     (@line.include?(': warning: ')) or
     (@line.include?(".cpp: In static member function '")) or
     (@line.include?(": In function '") and @line.include?("':")) or
     (@line.include?('     ^~~~~~')) or
     (@line.end_with?('      ^')) or
     (@line.start_with?('Warn: '))
    # ===================================================================== #
    # We will colourize such lines in red - or rather, whatever the
    # method colour_for_warnings_and_errors() will assign to this line.
    # ===================================================================== #
    @line = colour_for_warnings_and_errors(
      Colours.remove_escape_sequences(@line)
    )
  end
  # ======================================================================= #
  # === General error handling past this point
  # ======================================================================= #
  if @line.start_with?("Couldn't find include") or
     @line.start_with?('configure: error:') or
     @line.include?('ld: warning:') or
    (@line.include?('fatal error: ') and @line.include?('.h: No such file or directory')) or
    (@line.start_with?('sh: ') and @line.include?('configure: No such file or directory'))
    @line = colourize_this_error(@line)
  # ======================================================================= #
  # === Cmake warning that "a required package was not found"
  # ======================================================================= #
  elsif @line.include?('A required package was not found') or
        @line.include?('-- Configuring incomplete, errors occurred!') or
        @line.include?('CMake Error at ') or
        @line.include?('  file RENAME failed to rename')
    @line = colourize_this_error(@line)
  # ======================================================================= #
  # === CMake Warning
  # ======================================================================= #
  elsif @line.include?('CMake Warning')
    @line.sub!(/(CMake Warning)/, colourize_this_warning('\\1'))
  # ======================================================================= #
  # === Cmake could not find OPTIONAL or RECOMMENDED packages
  # ======================================================================= #
  elsif @line.include?('-- The following OPTIONAL packages have not been found:') or
        @line.include?('-- The following RECOMMENDED packages have not been found:') or
        @line.include?('-- The following features have been disabled:')
    @line = colourize_this_warning(@line)
  # ======================================================================= #
  # === Colourize config.log entries
  # ======================================================================= #
  elsif @line.include?('config.log')
    @line.sub!(/(config\.log)/, sfile('\\1'))
  end
  # ======================================================================= #
  # === Simple line-colourizers start in this if clause
  #
  # Entries added past this point MUST colourize the WHOLE line -
  # otherwise they are simply not allowed to be here at all.
  # Additionally, colours for errors or warnings are NOT allowed here
  # either. Use earlier entry points for these.
  # ======================================================================= #
  # ======================================================================= #
  # === "install -c -m" or "install -c ./" or "install -c -m" or
  #     "mkdir -p "
  # ======================================================================= #
  if @line.include?('install -c -m') or
     @line.include?('install -c ./') or
     @line.include?('install -c ')   or
     @line.include?('mkdir -p ')     or
     @line.include?('ln -s -f')
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === CSC lines
  #
  # The project called "mono" makes use of these, for example.
  # ======================================================================= #
  elsif @line.include?('CSC     [basic]') or # For mono and similar variants.
        @line.include?('     [build-linux] ') # <- This includes 'CSC' and 'AOT', too.
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === This clause handles 'WARNING: Using xyz' or
  #     lines with ^~~~~~~~.
  # ======================================================================= #         
  elsif @line.start_with?('WARNING: ') or
        @line.start_with?('   ^~~~~~~~~~~~~~~~~~~~~~~~')
    @line = colourize_for_warnings(@line)
  # ======================================================================= #
  # === Updating Gtk icon cache.
  # ======================================================================= #
  elsif @line.include?('Updating Gtk icon cache.')
    @line = gray(@line)
  # ======================================================================= #
  # === "Libraries have been installed in:"
  # ======================================================================= #
  elsif @line.include?('Libraries have been installed in:')
    @line = lightsteelblue(@line)
  # ======================================================================= #
  # === Handle KDE-runtime and optional packages
  #
  # This class will also handle (cmake-related) entries such as:
  #
  #  '-- The following REQUIRED packages have been found:'
  #
  # The four entry points include RUNTIME packages, OPTIONAL packages,
  # REQUIRED packages and RECOMMENDED packages.
  # ======================================================================= #
  elsif @line.include?('-- The following RUNTIME packages have been found:')  or
        @line.include?('-- The following OPTIONAL packages have been found:') or
        @line.include?('-- The following REQUIRED packages have been found:') or
        @line.include?('-- The following RECOMMENDED packages have been found:')
    @line = skyblue(@line)
  # ======================================================================= #
  # === "-- Looking for include file getopt.h - found"
  # ======================================================================= #
  elsif @line.include?('-- Looking for include file') and 
        @line.include?(' - found') # <- and include " - found".
    use_this_regex = /(-- Looking for include file )(.+.h)( - )([a-z]+)/ # See: https://rubular.com/r/lGSyJHlmd8HGfd
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')+'\3'+colour_for_found('\4')
    )
  # ======================================================================= #
  # === "-- Looking for include file getopt.h
  # ======================================================================= #
  elsif @line.include?('-- Looking for include file') and
       !@line.include?(' - found') # <- and NOT include " - found".
    use_this_regex = /(-- Looking for include file )(.+.h)/ # See: https://rubular.com/r/lGSyJHlmd8HGfd
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')
    )
  # ======================================================================= #
  # === "-- Looking for setmntent"
  #
  # This entry point really checks only for a one-word entry.
  # ======================================================================= #
  elsif @line.include?('-- Looking for ')
    use_this_regex = /^(-- Looking for )(\w+)$/ # See: https://rubular.com/r/SGXkPGeCStr7mo
    # ===================================================================== #
    # And append a colourized "- found" variant.
    # ===================================================================== #
    if stripped_line.end_with?(' - found')
      @line.sub!(/(found)$/, colour_for_found('\1'))
    end
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')
    )
  # ======================================================================= #
  # === Build Configuration:
  # ======================================================================= #
  elsif @line.include?('Build Configuration:')
    @line = orchid(@line)
  # ======================================================================= #
  # === The line ends with " - found"
  # ======================================================================= #
  elsif @line.end_with?(' - found')
    @line.sub!(/(found)$/, colour_for_found('\1'))
  # ======================================================================= #
  # === Colourize existing directories
  # ======================================================================= #
  elsif File.directory?(stripped_line)
    @line = sdir(stripped_line)
  end
  return @line # Also return it here, so that other programs can use this return value.
end

#set_line(i = '') ⇒ Object Also known as: grab_this_line

#

set_line

#


59
60
61
62
63
64
65
# File 'lib/rbt/misc/colourize_parser.rb', line 59

def set_line(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup.chomp # We also .chomp on the input.
  @line = i
  sanitize_line if use_colours?
  return @line
end