void __serial_print(const char* str, size_t len) { init_if_needed(); for (size_t i = 0; i < len; i++) { while (not (hw::inb(port + 5) & 0x20)); hw::outb(port, str[i]); } }
char *file__get_path(const char *filename) { init_if_needed(); static char path[path_len]; snprintf(path, path_len, "%s\\%s", homedir, filename); return path; }
void __serial_print1(const char* cstr) { init_if_needed(); while (*cstr) { while (not (hw::inb(port + 5) & 0x20)); hw::outb(port, *cstr++); } }
void gl_timer__checkpoint(const char *name) { assert(name); init_if_needed(); end_current_query(name); handle_read_data_if_ready(); start_new_query(); }
cursor__Type cursor__get() { init_if_needed(); HCURSOR c = GetCursor(); for (int i = 0; i < 3; ++i) { if (c == cursors[i]) return i; } return cursor__other; }
void WINAPI GetPluginInfoW(PluginInfo* info) { info->StructSize = sizeof(PluginInfo); ObjectArray<DeviceInfo> dev_list; try { init_if_needed(); get_device_list(dev_list); } catch (...) { dev_list.clear(); } if (dev_list.size() == 0) { if (g_plugin_options.last_dev_type == dtPDA) disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_PDA); else if (g_plugin_options.last_dev_type == dtSmartPhone) disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_SMARTPHONE); else disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_PDA); } else { if (dev_list[0].platform == L"PocketPC") { disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_PDA); g_plugin_options.last_dev_type = dtPDA; } else if (dev_list[0].platform == L"SmartPhone") { disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_SMARTPHONE); g_plugin_options.last_dev_type = dtSmartPhone; } else { disk_menu[0] = far_msg_ptr(MSG_DISK_MENU_PDA); g_plugin_options.last_dev_type = dtPDA; } save_plugin_options(g_plugin_options); } if (g_plugin_options.add_to_disk_menu) { info->DiskMenu.Strings = disk_menu; info->DiskMenu.Guids = &c_disk_menu_guid; info->DiskMenu.Count = ARRAYSIZE(disk_menu); } if (g_plugin_options.add_to_plugin_menu) { plugin_menu[0] = far_msg_ptr(MSG_PLUGIN_NAME); info->PluginMenu.Strings = plugin_menu; info->PluginMenu.Guids = &c_plugin_menu_guid; info->PluginMenu.Count = ARRAYSIZE(plugin_menu); } config_menu[0] = far_msg_ptr(MSG_PLUGIN_NAME); info->PluginConfig.Strings = config_menu; info->PluginConfig.Guids = &c_config_menu_guid; info->PluginConfig.Count = ARRAYSIZE(config_menu); info->CommandPrefix = g_plugin_format.data(); }
draw__Bitmap draw__new_bitmap(int w, int h) { init_if_needed(); int bytes_per_row = w * 4; draw__Bitmap bitmap = CGBitmapContextCreate(NULL, // data w, h, 8, // bits per component bytes_per_row, generic_rgb_colorspace, (CGBitmapInfo)kCGImageAlphaPremultipliedLast); // Make (0, 0) correspond to the lower-left corner. CGContextTranslateCTM(bitmap, 0, h); CGContextScaleCTM(bitmap, 1.0, -1.0); return bitmap; }
void gl_timer__add_callback(const char *from, const char *to, gl_timer__Callback cb) { assert(from); assert(to); assert(cb); init_if_needed(); // Retrieve the map (from_name -> callback). map__key_value *pair = map__find(checkpoint_callbacks, (void *)to); if (pair == NULL) { pair = map__set(checkpoint_callbacks, (void *)to, map__new(str_hash, str_eq)); } Map cbs_from_name = (Map)pair->value; // We expect that no callback has already be set for this from/to pair. assert(map__find(cbs_from_name, (void *)from) == NULL); map__set(cbs_from_name, (void *)from, cb); // Add the new callback. }
void cursor__set(cursor__Type which_cursor) { init_if_needed(); SetCursor(cursors[which_cursor]); }
HANDLE WINAPI OpenW(const OpenInfo* info) { try { if (info->OpenFrom == OPEN_COMMANDLINE) { // test if plugin is already open on active panel for (unsigned i = 0; i < g_plugin_objects.size(); i++) { PanelInfo pi; if (far_control_ptr(g_plugin_objects[i], FCTL_GETPANELINFO, &pi)) { if (pi.Flags & PFLAGS_FOCUS) { // change current directory of active plugin set_dir(g_plugin_objects[i], reinterpret_cast<OpenCommandLineInfo*>(info->Data)->CommandLine, true); far_control_int(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, 0); PanelRedrawInfo pri = { sizeof(PanelRedrawInfo) }; pri.CurrentItem = 0; pri.TopPanelItem = 0; far_control_ptr(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, &pri); // do not create new plugin instance return nullptr; } } } } init_if_needed(); ObjectArray<DeviceInfo> dev_list; get_device_list(dev_list); if (dev_list.size() == 0) FAIL(MsgError(far_get_msg(MSG_ERR_NO_DEVICE))); intptr_t mi = 0; if (dev_list.size() > 1) { ObjectArray<UnicodeString> menu_str; for (unsigned i = 0; i < dev_list.size(); i++) { menu_str += UnicodeString::format(L"%S %S (%S)", &dev_list[i].name, &dev_list[i].platform, &dev_list[i].con_type); } mi = far_menu(c_device_list_menu_guid, far_get_msg(MSG_DEVICE_LIST_TITLE), menu_str); if (mi == -1) BREAK; } PluginInstance* plugin = new PluginInstance(); try { plugin->device_info = dev_list[mi]; create_session(plugin->device_info.id, plugin); if (info->OpenFrom == OPEN_COMMANDLINE) { // directory is specified on command line plugin->current_dir = reinterpret_cast<OpenCommandLineInfo*>(info->Data)->CommandLine; if (!dir_exists(plugin->current_dir, plugin->session)) plugin->current_dir = L"\\"; } else if (g_plugin_options.save_last_dir) { // restore last directory plugin->current_dir = load_last_dir(plugin->device_info.strid()); if (!dir_exists(plugin->current_dir, plugin->session)) plugin->current_dir = L"\\"; } else { plugin->current_dir = L"\\"; } NOFAIL(refresh_system_info(plugin)); g_plugin_objects += plugin; } catch (...) { delete plugin; throw; } return plugin; } catch (Break&) { } catch (MsgError& e) { msg_dlg(e.message()); } catch (Error& e) { LOG_ERR(e); error_dlg(e, far_get_msg(MSG_ERR_PLUGIN_INIT)); } catch (...) { far_message(c_error_dialog_guid, L"\nFailure!", 0, FMSG_WARNING | FMSG_MB_OK); } return nullptr; }