Optional<coord> get_pixel_to_mm_conversion(const Image& image){ return image.GetCalibration().Visit( [](const Calibration& c) -> Optional<coord>{ return c.unit == "mm" ? option(c.length / length(c.pixelLine)) : no_option(); }, []() -> Optional<coord>{ return no_option(); }); }
Optional<Size> clipboard_get_size(){ Clipboard clip; if (!clip.Good()){ return no_option(); } else if (auto maybeStr = clip.GetText()){ return deserialize_size(maybeStr.Get()); } return no_option(); }
Optional<FilePath> make_absolute_file_path(const utf8_string& path){ wxFileName pathWX(to_wx(path)); if (!pathWX.IsOk()){ return no_option(); } pathWX = absoluted(pathWX); return option(FilePath::FromAbsoluteWx(pathWX)); }
int op_i(t_env **env, char **args, int i[2]) { char *var[2]; var[0] = "*"; var[1] = NULL; b_unsetenv(env, NULL, var, 0); if (!args[i[0] + 1]) no_option(env, '\n'); return (EXIT_SUCCESS); }
int op_u(t_env **env, char **args, int i[2]) { char *var[2]; i[0]++; if (!args[i[0]] || !args[i[0]][0]) { fprintf(stderr, "%s%s", NEEDS_ARG1, NEEDS_ARG2); return (EXIT_FAILURE); } var[0] = args[i[0]]; var[1] = NULL; b_unsetenv(env, NULL, var, 0); if (!args[i[0] + 1]) no_option(env, '\n'); return (EXIT_SUCCESS); }
static int part_two(t_path **tmp, t_path **actual, t_room **room, t_path **res) { *tmp = *actual; while (*tmp && (*tmp)->next) *tmp = (*tmp)->next; if (!*tmp) *actual = ft_create_path(*room); else (*tmp)->next = ft_create_path(*room); *res = NULL; *tmp = NULL; if ((*room)->is_end) { erase_last_one(*actual); return (1); } if (!(*room)->is_end && no_option((*room)->links, *actual)) { erase_last_one(*actual); return (2); } return (-1); }
static Optional<TextChange> handle_command_key(const KeyPress& key, ObjText* obj) { auto toggler = [obj](const BoolSetting& setting, const utf8_string& name){ auto setter = [obj](const auto& setting, const auto& value){ return [obj, setting, value](){ return obj->Set(setting, value); }; }; auto value = obj->GetSettings().Get(setting); return TextChange(setter(setting, !value), setter(setting, value), value ? "Clear " + name : "Set " + name); }; if (key.Is(Ctrl, key::B)){ return option(toggler(ts_FontBold, "bold")); } else if (key.Is(Ctrl, key::I)){ return option(toggler(ts_FontItalic, "italic")); } return no_option(); }
int op_0(t_env **env, char **args, int i[2]) { if (!args[i[0] + 1]) no_option(env, 0); return (EXIT_SUCCESS); }