Skip to content

Commit

Permalink
add sleep command
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Nov 6, 2023
1 parent 29736a3 commit e51c0a1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions res/resources/defaults/tiny.vindrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ command i <to_insert>

" @ System Commands
command exit <exit>
command sleep <sleep>
command set <set>
command map <map>
command noremap <noremap>
Expand Down
2 changes: 2 additions & 0 deletions src/bind/bindinglist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "bindedfunc.hpp"

#include "ctrl/guictrl.hpp"
#include "ctrl/sleep.hpp"

#include "emu/changetext.hpp"
#include "emu/deltext.hpp"
Expand Down Expand Up @@ -107,6 +108,7 @@ namespace vind
Execute::create(),
ExitConfigGUI::create(),
Exit::create(),
Sleep::create(),
ForwardUINavigation::create(),
GotoNextPage::create(),
GotoPrevPage::create(),
Expand Down
33 changes: 33 additions & 0 deletions src/bind/ctrl/sleep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "sleep.hpp"

#include <windows.h>

#include "util/debug.hpp"
#include "util/def.hpp"
#include "util/string.hpp"


namespace vind
{
namespace bind
{
Sleep::Sleep()
: BindedFuncVoid("sleep")
{}
void Sleep::sprocess(
std::uint16_t count,
const std::string& args) {
if(!args.empty()) {
count = util::extract_num<std::uint16_t>(args) ;

if(args.back() != 'm') {
count *= 1000 ; // convert the seconds into miliseconds
}
}
else {
count *= 1000 ; // assume the input is always seconds unit.
}
::Sleep(static_cast<DWORD>(count)) ;
}
}
}
14 changes: 14 additions & 0 deletions src/bind/ctrl/sleep.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#ifndef _SLEEP_HPP
#define _SLEEP_HPP

#include "bind/bindedfunc.hpp"

namespace vind
{
namespace bind
{
struct Sleep : public BindedFuncVoid<Sleep> {
explicit Sleep() ;
static void sprocess(
std::uint16_t count, const std::string& args) ;
} ;
}
}

#endif
2 changes: 1 addition & 1 deletion src/core/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _VERSION_HPP
#define _VERSION_HPP

#define WIN_VIND_VERSION "5.5.1.0"
#define WIN_VIND_VERSION "5.5.2.0"

#endif

0 comments on commit e51c0a1

Please sign in to comment.