Skip to content

Commit

Permalink
add get_pid func
Browse files Browse the repository at this point in the history
  • Loading branch information
endaaman committed Feb 21, 2022
1 parent eb8f5c1 commit c1c3d70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ tym.set_keymaps({
| `tym.get_text(start_row, start_col, end_row, end_col)` | string | Get text on the terminal screen. If you set `-1` to `end_row` and `end_col`, the target area will be the size of termianl. |
| `tym.get_config_path()` | string | Get full path to config file. |
| `tym.get_theme_path()` | string | Get full path to theme file. |
| `tym.get_pid()` | integer | Get pid. |
| `tym.get_version()` | string | Get version string. |

### Hooks
Expand Down
7 changes: 7 additions & 0 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ static int builtin_get_version(lua_State* L)
return 1;
}

static int builtin_get_pid(lua_State* L)
{
lua_pushinteger(L, getpid());
return 1;
}

static int builtin_apply(lua_State* L)
{
Context* context = (Context*)lua_touserdata(L, lua_upvalueindex(1));
Expand Down Expand Up @@ -728,6 +734,7 @@ int builtin_register_module(lua_State* L)
{ "get_text" , builtin_get_text },
{ "get_config_path" , builtin_get_config_path },
{ "get_theme_path" , builtin_get_theme_path },
{ "get_pid" , builtin_get_pid },
{ "get_version" , builtin_get_version },
// DEPRECATED
{ "apply" , builtin_apply },
Expand Down

0 comments on commit c1c3d70

Please sign in to comment.