Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add escape1 for escape sequences with one parameter

  • Loading branch information...
commit 760190349b5bde2c6dc336bb2b64cd41c2783667 1 parent d7894dd
@doy authored
Showing with 23 additions and 0 deletions.
  1. +5 −0 src/curses_helper.c
  2. +18 −0 src/info.rs
View
5 src/curses_helper.c
@@ -1,6 +1,11 @@
#include <curses.h>
#include <term.h>
+char *tiparm1(const char *name, int p1)
+{
+ return tiparm(name, p1);
+}
+
char *tiparm2(const char *name, int p1, int p2)
{
return tiparm(name, p1, p2);
View
18 src/info.rs
@@ -12,6 +12,14 @@ pub fn escape (name: &str) -> ~str {
}
}
+pub fn escape1 (name: &str, p1: int) -> ~str {
+ do str::as_c_str(name) |c_name| {
+ unsafe {
+ str::raw::from_c_str(tiparm1(tigetstr(c_name), p1))
+ }
+ }
+}
+
pub fn escape2 (name: &str, p1: int, p2: int) -> ~str {
do str::as_c_str(name) |c_name| {
unsafe {
@@ -33,6 +41,15 @@ unsafe fn tigetstr (name: *c_char) -> *c_char {
c_out
}
+unsafe fn tiparm1 (name: *c_char, p1: int) -> *c_char {
+ let ret = helper::tiparm1(name, p1 as c_int);
+ if ret == ptr::null() {
+ fail!(fmt!("Couldn't assemble parameters with %s %d",
+ unsafe { str::raw::from_c_str(name) }, p1));
+ }
+ ret
+}
+
unsafe fn tiparm2 (name: *c_char, p1: int, p2: int) -> *c_char {
let ret = helper::tiparm2(name, p1 as c_int, p2 as c_int);
if ret == ptr::null() {
@@ -51,5 +68,6 @@ extern mod c {
// tiparm uses varargs, which you can't bind from rust yet
#[link_name = "curses_helper"]
extern mod helper {
+ fn tiparm1(s: *c_char, p1: c_int) -> *c_char;
fn tiparm2(s: *c_char, p1: c_int, p2: c_int) -> *c_char;
}
Please sign in to comment.
Something went wrong with that request. Please try again.