Changeset bdbec0aacb083e63e1d0061e44722f3b1a05942f
- Timestamp:
- 10/23/09 15:49:11 (5 weeks ago)
- Author:
- Karl Ramm <kcr@1ts.org>
- git-author:
- Karl Ramm <kcr@1ts.org> / 2009-09-25T11:18:41Z-0400
- Parents:
- fb7742c26c2c6ef87a9fafbc1dd594987d2ef4c9
- Children:
- b644688634a207e3728488699f24f96fd01c6cfc
- git-committer:
- Karl Ramm <kcr@1ts.org> / 2009-10-23T15:49:11Z-0400
- Message:
-
refactor and clean owl editwin startup functions
Take function.c:owl_function_{z,aim}write_setup and perlglue.xs:start_edit_win,
and collide at .8c producing owl_function_write_setup which calls
owl_function_start_edit_win.
(Also ditching another three fugly char[1024]s)
Really, this ought to be in perl.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rb7ee89b
|
rbdbec0a
|
|
| 281 | 281 | } |
| 282 | 282 | |
| | 283 | void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data) |
| | 284 | { |
| | 285 | owl_editwin *e; |
| | 286 | char *s; |
| | 287 | |
| | 288 | /* create and setup the editwin */ |
| | 289 | e = owl_global_get_typwin(&g); |
| | 290 | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
| | 291 | owl_global_get_msg_history(&g)); |
| | 292 | owl_editwin_clear(e); |
| | 293 | owl_editwin_set_dotsend(e); |
| | 294 | s = owl_sprintf("----> %s\n", line); |
| | 295 | owl_editwin_set_locktext(e, s); |
| | 296 | owl_free(s); |
| | 297 | |
| | 298 | /* make it active */ |
| | 299 | owl_global_set_typwin_active(&g); |
| | 300 | |
| | 301 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), data); |
| | 302 | owl_global_set_buffercallback(&g, callback); |
| | 303 | } |
| | 304 | |
| | 305 | static void owl_function_write_setup(const char *line, const char *noun, void (*callback)(owl_editwin *)) |
| | 306 | { |
| | 307 | |
| | 308 | if (!owl_global_get_lockout_ctrld(&g)) |
| | 309 | owl_function_makemsg("Type your %s below. " |
| | 310 | "End with ^D or a dot on a line by itself." |
| | 311 | " ^C will quit.", noun); |
| | 312 | else |
| | 313 | owl_function_makemsg("Type your %s below. " |
| | 314 | "End with a dot on a line by itself. ^C will quit.", |
| | 315 | noun); |
| | 316 | |
| | 317 | owl_function_start_edit_win(line, callback, NULL); |
| | 318 | owl_global_set_buffercommand(&g, line); |
| | 319 | } |
| | 320 | |
| 283 | 321 | void owl_function_zwrite_setup(const char *line) |
| 284 | 322 | { |
| 285 | | owl_editwin *e; |
| 286 | | char buff[1024]; |
| 287 | 323 | owl_zwrite z; |
| 288 | 324 | int ret; |
| … |
… |
|
| 302 | 338 | owl_zwrite_free(&z); |
| 303 | 339 | |
| 304 | | /* create and setup the editwin */ |
| 305 | | e=owl_global_get_typwin(&g); |
| 306 | | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g)); |
| 307 | | |
| 308 | | if (!owl_global_get_lockout_ctrld(&g)) { |
| 309 | | owl_function_makemsg("Type your zephyr below. End with ^D or a dot on a line by itself. ^C will quit."); |
| 310 | | } else { |
| 311 | | owl_function_makemsg("Type your zephyr below. End with a dot on a line by itself. ^C will quit."); |
| 312 | | } |
| 313 | | |
| 314 | | owl_editwin_clear(e); |
| 315 | | owl_editwin_set_dotsend(e); |
| 316 | | strcpy(buff, "----> "); |
| 317 | | strncat(buff, line, 1016); |
| 318 | | strcat(buff, "\n"); |
| 319 | | owl_editwin_set_locktext(e, buff); |
| 320 | | |
| 321 | | /* make it active */ |
| 322 | | owl_global_set_typwin_active(&g); |
| 323 | | |
| 324 | | owl_global_set_buffercommand(&g, line); |
| 325 | | owl_global_set_buffercallback(&g, &owl_callback_zwrite); |
| | 340 | owl_function_write_setup(line, "zephyr", &owl_callback_zwrite); |
| 326 | 341 | } |
| 327 | 342 | |
| 328 | 343 | void owl_function_aimwrite_setup(const char *line) |
| 329 | 344 | { |
| 330 | | owl_editwin *e; |
| 331 | | char buff[1024]; |
| 332 | | |
| 333 | | /* check the arguments */ |
| 334 | | |
| 335 | | /* create and setup the editwin */ |
| 336 | | e=owl_global_get_typwin(&g); |
| 337 | | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g)); |
| 338 | | |
| 339 | | if (!owl_global_get_lockout_ctrld(&g)) { |
| 340 | | owl_function_makemsg("Type your message below. End with ^D or a dot on a line by itself. ^C will quit."); |
| 341 | | } else { |
| 342 | | owl_function_makemsg("Type your message below. End with a dot on a line by itself. ^C will quit."); |
| 343 | | } |
| 344 | | |
| 345 | | owl_editwin_clear(e); |
| 346 | | owl_editwin_set_dotsend(e); |
| 347 | | strcpy(buff, "----> "); |
| 348 | | strcat(buff, line); |
| 349 | | strcat(buff, "\n"); |
| 350 | | owl_editwin_set_locktext(e, buff); |
| 351 | | |
| 352 | | /* make it active */ |
| 353 | | owl_global_set_typwin_active(&g); |
| 354 | | |
| 355 | | owl_global_set_buffercommand(&g, line); |
| 356 | | owl_global_set_buffercallback(&g, &owl_callback_aimwrite); |
| | 345 | owl_function_write_setup(line, "message", &owl_callback_aimwrite); |
| 357 | 346 | } |
| 358 | 347 | |
-
|
rdcc3f80
|
rbdbec0a
|
|
| 203 | 203 | const char *line |
| 204 | 204 | SV *callback |
| 205 | | PREINIT: |
| 206 | | owl_editwin * e; |
| 207 | | char buff[1024]; |
| 208 | 205 | CODE: |
| 209 | 206 | { |
| … |
… |
|
| 211 | 208 | croak("Callback must be a subref"); |
| 212 | 209 | |
| 213 | | e = owl_global_get_typwin(&g); |
| 214 | | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
| 215 | | owl_global_get_msg_history(&g)); |
| 216 | | owl_editwin_clear(e); |
| 217 | | owl_editwin_set_dotsend(e); |
| 218 | | snprintf(buff, 1023, "----> %s\n", line); |
| 219 | | owl_editwin_set_locktext(e, buff); |
| 220 | | |
| 221 | | owl_global_set_typwin_active(&g); |
| 222 | | |
| 223 | | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
| 224 | | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
| | 210 | owl_function_start_edit_win(line, owl_perlconfig_edit_callback, SvREFCNT_inc(callback)); |
| 225 | 211 | } |
| 226 | 212 | |