mylisp/gds-sabre.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 25 Jul 2022 11:38:25 +0300
changeset 1756 2495ee9cf84c
parent 1747 b7d3a5fd4059
permissions -rw-r--r--
x-select-enable-clipboard => select-enable-clipboard

;;;###autoload
(defun gds-sabre-decode-region (&optional beg end prefix)
  "Decode garbage coming from UTF8 terminals when Sabre operates in iso-8859-1."
  (interactive "r\nP")
  (unless beg (setq beg (region-beginning)))
  (unless end (setq end (region-end)))
  (let (text)
    (setq text
          (decode-coding-string
           (encode-coding-string
            (decode-coding-string
             (encode-coding-string (buffer-substring beg end) 'iso-8859-1)
             'utf-8)
            'iso-8859-1)
           'cp1252))
    (when prefix
      (delete-region beg end)
      (insert text))
    text))

;;;###autoload
(defun gds-sabre-highlight-getres ()
  (interactive)
  (highlight-regexp " \\(?:[[:alpha:]_]*PseudoCityCode\\|CreationAgent\\|BookingSource\\|AgentSine\\)=\"\\([^\"]+\\)\"" 'hi-pink 1)
  (highlight-regexp "<\\([[:alnum:]]*:?\\)\\(RecordLocator\\|DepartureAirport\\|ArrivalAirport\\|MarketingAirlineCode\\|MarketingFlightNumber\\)>\\([^<]+\\)</\\1\\2>" 'hi-pink 3)
  (highlight-phrase ":Arunk\\|:FlightSegment\\>\\|:FareBasis\\>" 'hi-pink)
  (highlight-regexp "<\\([[:alnum:]]+:\\)?\\(ActionCode\\|ClassOfService\\|MarketingClassOfService\\|InputEntry\\|PricingParameters\\|FullText\\)>\\([^<]+\\)</\\1?\\2>" 'hi-yellow 3)
  (highlight-phrase "\\(?:isPast\\|isExpired\\|itineraryChange\\|latestPQFlag\\)=\"[^\"]+\"" 'hi-green)
  (highlight-regexp "\\(?:ResBookDesigCode\\|Status\\|FlightNumber\\|ArrivalDateTime\\|DepartureDateTime\\|FareBasisCode\\|passengerType\\|sequence\\)=\"\\([^\"]+\\)\"" 'hi-green 1)
  (highlight-phrase "InputMessage=" 'hi-blue))

(defvar gds-sabre-highlight-ssrs
  (regexp-opt
   '("ADV OTO TKT" "ADV MORE TKT" "TO AVOID AUTO CXL"
     "CNLD AS NOT TKTD" "CANCELLED DUE TO SYSTEM OR PASSENGER"
     "REMINDER UA SEGS SUBJ TO CXL ON" "UA SEGS XLD"
     "OTHERWISE WILL BE CANCEL" "PLS ADV TKT NBR BY"
     "OTHERWISE WILL BE XLD"
     "PLS ADV TKTNUMBR FOR"
     "CANCELLATION DUE TO NO TICKET"
     "BKG CXLD DUE TO TKT TIME EXPIRED"
     "RITK/ADTKT BY"
     "OR CXL"
     "ADTK" "ADMD"
     "OTHERWISE WILL BE"
     "OR SPACE WILL BE"
     "CXLD AUTOMATICALLY"
     "TIME ZONE"
     "LT ELSE BKG WILL")))

;;;###autoload
(defun gds-sabre-highlight-hist ()
  (interactive)
  (highlight-regexp "^\\(?:SC\\|AS\\|XS\\)  .*" 'hi-yellow)
  (highlight-regexp gds-sabre-highlight-ssrs 'hi-pink)
  (highlight-regexp "^[A-Z0-9]\\{4\\} [A-Z0-9]\\{4\\}\\*[A-Z0-9]\\{3\\} [0-9]\\{4\\}/[0-9]\\{2\\}[A-Z]\\{3\\}[0-9]\\{2\\}" 'hi-blue 0)
  (highlight-regexp "^PLT PLTRM[A-Z0-9]\\{2\\} .*" 'hi-green 0))

;;;###autoload
(defun gds-tp-highlight ()
  (interactive)
  (highlight-phrase "\\w+Ref=\\|Key=" 'hi-blue)
  (highlight-phrase "ProviderCode" 'hi-pink)
  (highlight-phrase "\\w*LocatorCode" 'hi-pink)
  (highlight-phrase "OwningPCC" 'hi-pink)
  (highlight-phrase "FareBasis" 'hi-green)
  (highlight-phrase "CabinClass" 'hi-green)
  (highlight-phrase "BookingCode" 'hi-green)
  (highlight-phrase "FareBasis" 'hi-green)
  (highlight-phrase "ClassOfService" 'hi-green)
  (highlight-phrase "Status=" 'hi-green)
  (highlight-phrase "\\w*TotalPrice" 'hi-green))

(provide 'gds-sabre)