@@ -74,6 +74,11 @@ ZEND_END_ARG_INFO()
7474ZEND_BEGIN_ARG_INFO_EX (format_number_arginfo , 0 , 0 , 1 )
7575 ZEND_ARG_INFO (0 , format )
7676ZEND_END_ARG_INFO ()
77+
78+ ZEND_BEGIN_ARG_INFO_EX (format_background_arginfo , 0 , 0 , 2 )
79+ ZEND_ARG_INFO (0 , pattern )
80+ ZEND_ARG_INFO (0 , color )
81+ ZEND_END_ARG_INFO ()
7782/* }}} */
7883
7984/** {{{ \Vtiful\Kernel\Format::__construct()
@@ -106,7 +111,10 @@ PHP_METHOD(vtiful_format, bold)
106111 ZVAL_COPY (return_value , getThis ());
107112
108113 format_object * obj = Z_FORMAT_P (getThis ());
109- format_set_bold (obj -> ptr .format );
114+
115+ if (obj -> ptr .format ) {
116+ format_set_bold (obj -> ptr .format );
117+ }
110118}
111119/* }}} */
112120
@@ -117,7 +125,10 @@ PHP_METHOD(vtiful_format, italic)
117125 ZVAL_COPY (return_value , getThis ());
118126
119127 format_object * obj = Z_FORMAT_P (getThis ());
120- format_set_italic (obj -> ptr .format );
128+
129+ if (obj -> ptr .format ) {
130+ format_set_italic (obj -> ptr .format );
131+ }
121132}
122133/* }}} */
123134
@@ -134,7 +145,10 @@ PHP_METHOD(vtiful_format, underline)
134145 ZVAL_COPY (return_value , getThis ());
135146
136147 format_object * obj = Z_FORMAT_P (getThis ());
137- format_set_underline (obj -> ptr .format , style );
148+
149+ if (obj -> ptr .format ) {
150+ format_set_underline (obj -> ptr .format , style );
151+ }
138152}
139153/* }}} */
140154
@@ -160,7 +174,9 @@ PHP_METHOD(vtiful_format, align)
160174 zend_throw_exception (vtiful_exception_ce , "Format exception, please view the manual" , 150 );
161175 }
162176
163- format_set_align (obj -> ptr .format , Z_LVAL_P (arg ));
177+ if (obj -> ptr .format ) {
178+ format_set_align (obj -> ptr .format , Z_LVAL_P (arg ));
179+ }
164180 }
165181}
166182/* }}} */
@@ -179,7 +195,9 @@ PHP_METHOD(vtiful_format, color)
179195
180196 format_object * obj = Z_FORMAT_P (getThis ());
181197
182- format_set_font_color (obj -> ptr .format , color );
198+ if (obj -> ptr .format ) {
199+ format_set_font_color (obj -> ptr .format , color );
200+ }
183201}
184202/* }}} */
185203
@@ -197,7 +215,45 @@ PHP_METHOD(vtiful_format, number)
197215
198216 format_object * obj = Z_FORMAT_P (getThis ());
199217
200- format_set_num_format (obj -> ptr .format , ZSTR_VAL (format ));
218+ if (obj -> ptr .format ) {
219+ format_set_num_format (obj -> ptr .format , ZSTR_VAL (format ));
220+ }
221+ }
222+ /* }}} */
223+
224+ /** {{{ \Vtiful\Kernel\Format::background(int $pattern, int $color)
225+ */
226+ PHP_METHOD (vtiful_format , background )
227+ {
228+ zend_long pattern , color ;
229+
230+ ZEND_PARSE_PARAMETERS_START (2 , 2 )
231+ Z_PARAM_LONG (pattern )
232+ Z_PARAM_LONG (color )
233+ ZEND_PARSE_PARAMETERS_END ();
234+
235+ ZVAL_COPY (return_value , getThis ());
236+
237+ format_object * obj = Z_FORMAT_P (getThis ());
238+
239+ if (obj -> ptr .format ) {
240+ format_set_pattern (obj -> ptr .format , pattern );
241+ format_set_bg_color (obj -> ptr .format , color );
242+ }
243+ }
244+ /* }}} */
245+
246+ /** {{{ \Vtiful\Kernel\Format::wrap()
247+ */
248+ PHP_METHOD (vtiful_format , wrap )
249+ {
250+ ZVAL_COPY (return_value , getThis ());
251+
252+ format_object * obj = Z_FORMAT_P (getThis ());
253+
254+ if (obj -> ptr .format ) {
255+ format_set_text_wrap (obj -> ptr .format );
256+ }
201257}
202258/* }}} */
203259
@@ -215,14 +271,16 @@ PHP_METHOD(vtiful_format, toResource)
215271/** {{{ format_methods
216272*/
217273zend_function_entry format_methods [] = {
218- PHP_ME (vtiful_format , __construct , format_construct_arginfo , ZEND_ACC_PUBLIC )
219- PHP_ME (vtiful_format , bold , NULL , ZEND_ACC_PUBLIC )
220- PHP_ME (vtiful_format , italic , NULL , ZEND_ACC_PUBLIC )
221- PHP_ME (vtiful_format , underline , format_underline_arginfo , ZEND_ACC_PUBLIC )
222- PHP_ME (vtiful_format , align , format_align_arginfo , ZEND_ACC_PUBLIC )
223- PHP_ME (vtiful_format , color , format_color_arginfo , ZEND_ACC_PUBLIC )
224- PHP_ME (vtiful_format , number , format_number_arginfo , ZEND_ACC_PUBLIC )
225- PHP_ME (vtiful_format , toResource , NULL , ZEND_ACC_PUBLIC )
274+ PHP_ME (vtiful_format , __construct , format_construct_arginfo , ZEND_ACC_PUBLIC )
275+ PHP_ME (vtiful_format , wrap , NULL , ZEND_ACC_PUBLIC )
276+ PHP_ME (vtiful_format , bold , NULL , ZEND_ACC_PUBLIC )
277+ PHP_ME (vtiful_format , italic , NULL , ZEND_ACC_PUBLIC )
278+ PHP_ME (vtiful_format , align , format_align_arginfo , ZEND_ACC_PUBLIC )
279+ PHP_ME (vtiful_format , color , format_color_arginfo , ZEND_ACC_PUBLIC )
280+ PHP_ME (vtiful_format , number , format_number_arginfo , ZEND_ACC_PUBLIC )
281+ PHP_ME (vtiful_format , underline , format_underline_arginfo , ZEND_ACC_PUBLIC )
282+ PHP_ME (vtiful_format , toResource , NULL , ZEND_ACC_PUBLIC )
283+ PHP_ME (vtiful_format , background , format_background_arginfo , ZEND_ACC_PUBLIC )
226284 PHP_FE_END
227285};
228286/* }}} */
@@ -275,6 +333,26 @@ VTIFUL_STARTUP_FUNCTION(format) {
275333 REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "COLOR_WHITE" , LXW_COLOR_WHITE )
276334 REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "COLOR_YELLOW" , LXW_COLOR_YELLOW )
277335
336+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_NONE" , LXW_PATTERN_NONE )
337+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_SOLID" , LXW_PATTERN_SOLID )
338+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_MEDIUM_GRAY" , LXW_PATTERN_MEDIUM_GRAY )
339+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_GRAY" , LXW_PATTERN_DARK_GRAY )
340+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_GRAY" , LXW_PATTERN_LIGHT_GRAY )
341+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_HORIZONTAL" , LXW_PATTERN_DARK_HORIZONTAL )
342+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_VERTICAL" , LXW_PATTERN_DARK_VERTICAL )
343+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_DOWN" , LXW_PATTERN_DARK_DOWN )
344+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_UP" , LXW_PATTERN_DARK_UP )
345+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_GRID" , LXW_PATTERN_DARK_GRID )
346+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_DARK_TRELLIS" , LXW_PATTERN_DARK_TRELLIS )
347+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_HORIZONTAL" , LXW_PATTERN_LIGHT_HORIZONTAL )
348+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_VERTICAL" , LXW_PATTERN_LIGHT_VERTICAL )
349+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_DOWN" , LXW_PATTERN_LIGHT_DOWN )
350+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_UP" , LXW_PATTERN_LIGHT_UP )
351+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_GRID" , LXW_PATTERN_LIGHT_GRID )
352+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_LIGHT_TRELLIS" , LXW_PATTERN_LIGHT_TRELLIS )
353+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_GRAY_125" , LXW_PATTERN_GRAY_125 )
354+ REGISTER_CLASS_CONST_LONG (vtiful_format_ce , "PATTERN_GRAY_0625" , LXW_PATTERN_GRAY_0625 )
355+
278356 return SUCCESS ;
279357}
280358/* }}} */
0 commit comments