<commit_before>﻿////////////////////////////////////
// @file main.cc
// @brief Morse code generator
// @author <NAME>
// @date 2016-05-15 12:08:31
// Copyright 2016 <NAME>
////////////////////////////////////
#include <wchar.h>
#include <windows.h>
#include <stdio.h>
#include "common.h"
#include "morse_player.h"
#include "resource.h"
#define WINDOW_STYLE    (WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX)
enum OPTIONS {
  OPTION_HELP = 0,
  OPTION_STRING,
  OPTION_NOWINDOW,
  OPTION_NOSOUND,
  OPTION_WPM,
  OPTION_PARIS,
  ELEMNUM_OPTIONS, // Array size.
};
const wchar_t kOptions[ELEMNUM_OPTIONS][16] = {
  L"-help",        // OPTION_HELP
  L"-s",           // OPTION_STRING
  L"-nowindow",    // OPTION_NOWINDOW
  L"-nosound",     // OPTION_NOSOUND
  L"-wpm",         // OPTION_WPM
  L"-paris",       // OPTION_PARIS
};
const wchar_t kHelp[ELEMNUM_OPTIONS][64] = {
  L"Show help",                        // OPTION_HELP
  L"Input string to be morse signal",  // OPTION_STRING
  L"Not show output console",          // OPTION_NOWINDOW
  L"Not play midi sound",              // OPTION_NOSOUND
  L"Set WPM, default is 20",           // OPTION_WPM
  L"Set PARIS, default is 20",         // OPTION_PARIS
};
bool help_required = false;
bool no_console = false;
bool no_sound = false;
bool play_command_line_string = false;
int string_argc_offset = 0;
void ShowAndPlay(MorsePlayer* morse_player, wchar_t charactor);
bool CreateInvisibleWindow(HINSTANCE instance_handle);
int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE not_used,
                    LPTSTR cmd_lind, int cmd_show) {
  // Prevent warnings for unreferenced parameters.
  UNREFERENCED_PARAMETER(instance_handle);
  UNREFERENCED_PARAMETER(not_used);
  UNREFERENCED_PARAMETER(cmd_lind);
  UNREFERENCED_PARAMETER(cmd_show);
  //
  CreateInvisibleWindow(instance_handle);
  //
  MorsePlayer morse_player;
  morse_player.Initialize();
  morse_player.dot_len_ = 60;
  // Command line is processed.
  for (int i = 1; i < __argc; ++i) {
    for (int j = 0; j < ELEMNUM_OPTIONS; ++j) {
      if (wcscmp(__wargv[i], kOptions[j]) == 0) {
        switch (j) {
          case OPTION_HELP:
            help_required = true;
            break;
          case OPTION_NOWINDOW:
            no_console = true;
            break;
          case OPTION_NOSOUND:
            no_sound = true;
            break;
          case OPTION_WPM:  // Same as OPTION_PARIS
          case OPTION_PARIS:
            /* wpm (paris) -> dot millis */
            morse_player.dot_len_ = 60000 / (_wtoi(__wargv[i + 1]) * 50);
            break;
          case OPTION_STRING:
            play_command_line_string = true;
            string_argc_offset = i + 1;
          default:
            break;
        }
      }
    }<commit_msg>comment is /* -> //<commit_after>﻿////////////////////////////////////
// @file main.cc
// @brief Morse code generator
// @author <NAME>
// @date 2016-05-15 12:08:31
// Copyright 2016 <NAME>
////////////////////////////////////
#include <wchar.h>
#include <windows.h>
#include <stdio.h>
#include "common.h"
#include "morse_player.h"
#include "resource.h"
#define WINDOW_STYLE    (WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX)
enum OPTIONS {
  OPTION_HELP = 0,
  OPTION_STRING,
  OPTION_NOWINDOW,
  OPTION_NOSOUND,
  OPTION_WPM,
  OPTION_PARIS,
  ELEMNUM_OPTIONS, // Array size.
};
const wchar_t kOptions[ELEMNUM_OPTIONS][16] = {
  L"-help",        // OPTION_HELP
  L"-s",           // OPTION_STRING
  L"-nowindow",    // OPTION_NOWINDOW
  L"-nosound",     // OPTION_NOSOUND
  L"-wpm",         // OPTION_WPM
  L"-paris",       // OPTION_PARIS
};
const wchar_t kHelp[ELEMNUM_OPTIONS][64] = {
  L"Show help",                        // OPTION_HELP
  L"Input string to be morse signal",  // OPTION_STRING
  L"Not show output console",          // OPTION_NOWINDOW
  L"Not play midi sound",              // OPTION_NOSOUND
  L"Set WPM, default is 20",           // OPTION_WPM
  L"Set PARIS, default is 20",         // OPTION_PARIS
};
bool help_required = false;
bool no_console = false;
bool no_sound = false;
bool play_command_line_string = false;
int string_argc_offset = 0;
void ShowAndPlay(MorsePlayer* morse_player, wchar_t charactor);
bool CreateInvisibleWindow(HINSTANCE instance_handle);
int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE not_used,
                    LPTSTR cmd_lind, int cmd_show) {
  // Prevent warnings for unreferenced parameters.
  UNREFERENCED_PARAMETER(instance_handle);
  UNREFERENCED_PARAMETER(not_used);
  UNREFERENCED_PARAMETER(cmd_lind);
  UNREFERENCED_PARAMETER(cmd_show);
  //
  CreateInvisibleWindow(instance_handle);
  //
  MorsePlayer morse_player;
  morse_player.Initialize();
  morse_player.dot_len_ = 60;
  // Command line is processed.
  for (int i = 1; i < __argc; ++i) {
    for (int j = 0; j < ELEMNUM_OPTIONS; ++j) {
      if (wcscmp(__wargv[i], kOptions[j]) == 0) {
        switch (j) {
          case OPTION_HELP:
            help_required = true;
            break;
          case OPTION_NOWINDOW:
            no_console = true;
            break;
          case OPTION_NOSOUND:
            no_sound = true;
            break;
          case OPTION_WPM:  // Same as OPTION_PARIS
          case OPTION_PARIS:
            // wpm (paris) -> dot millis
            morse_player.dot_len_ = 60000 / (_wtoi(__wargv[i + 1]) * 50);
            break;
          case OPTION_STRING:
            play_command_line_string = true;
            string_argc_offset = i + 1;
          default:
            break;
        }
      }
    }
{'fraction_non_alphanumeric': 0.1325148943852681, 'fraction_numerical': 0.01516519227297346, 'mean_word_length': 2.235981308411215, 'pattern_counts': {'":': 0, '<': 17, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2378163', 'n_tokens_mistral': 2010, 'n_tokens_neox': 1918, 'n_words': 412}