/** * EmEditor でCSSを補完するマクロ * PHP と JavaScriptの補完も追加。 * @author takuya_1st * @update 2006/10/10 * @version 1.0 beta * @ref http://d.hatena.ne.jp/takuya_1st/20060929/1159485668 */ function Suggestion(){ this.delim = [ " ",":",";","\n", "\t", "\"", "'","{","}", "(", ")" ]; this.pickUpWords = new Array(); this.input = null; this.menu = CreatePopupMenu(); this.selected = 0; this.moved = 0; this.isDelim = function( str ){ for( var i in this.delim ){ if( str.indexOf( this.delim[i] ) >= 0 ){ return true; } } return false; } this.show = function () { this.select(); this.setLists(); this.pickup(); this.createMenu(); this.showMenu(); this.insert(); } this.showMenu = function(){ if( this.pickUpWords.length == 0 ){ return; } else if( this.pickUpWords.length == 1){ this.selected = 1; return; } this.selected = this.menu.Track(0); } this.select = function(){ var str = ""; var piece = ""; for( var i=0;i<100;i++ ){ document.selection.CharLeft( true, 1 ); str = document.selection.Text; this.moved++; if( this.isDelim( str ) ){ document.selection.Collapse(); document.selection.CharRight( false, this.moved ); this.moved--; break; } piece = str ; } this.input = piece; } this.insert = function(){ if( this.selected == 0 ){ return; } for( var i=0;i<100;i++ ){ document.selection.CharRight( true, 1 ); str = document.selection.Text; if( this.isDelim( str ) ){ document.selection.Collapse(); document.selection.CharLeft(); break; } this.moved++; } if(i==100){ this.moved = this.moved-100; } if( this.moved != 0 ){ document.selection.CharLeft( true, this.moved ); } if( document.selection.Text == this.menu.GetText( this.selected ) ){ document.selection.Collapse(); document.selection.CharRight( false, this.moved ); return; } document.selection.Text = this.menu.GetText( this.selected ); } this.createMenu = function () { for( var i in this.pickUpWords ){ this.menu.Add( this.pickUpWords[i], i+1 ); } } this.pickup = function (){ for(var i=0; i 50 || _a[i] == this.input ){ continue; } array[array.length++] = new String( _a[i] ); } var obj = new Object(); while( array.length > 0 ){ obj[array.shift()] = true; } for( i in obj ){ array.push( i ); } return array; } this.reservedWords = null; } function CssSuggestion(){ this.delim = [ " ",":",";","\n", "\t", "\"", "'","{","}" ]; this.reservedWords = [ 'azimuth','background','background-attachment', 'background-color','background-image', 'background-position','background-repeat', 'behavior','border','border-bottom', 'border-bottom-color','border-bottom-style', 'border-bottom-width','border-collapse', 'border-color','border-left','border-left-color', 'border-left-style','border-left-width','border-right', 'border-right-color','border-right-style', 'border-right-width','border-spacing','border-style', 'border-top','border-top-color','border-top-style', 'border-top-width','border-width','bottom', 'caption-side','clear','clip','color','content', 'counter-increment','counter-reset','cue', 'cue-after','cue-before','cursor','direction', 'display','elevation','empty-cells','filter','float', 'font','font-family','font-size-adjust','font-size', 'font-stretch','font-style','font-variant', 'font-weight','height','ime-mode','layout-grid', 'layout-grid-char','layout-grid-line','layout-grid-mode', 'layout-grid-type','left','letter-spacing','line-break', 'line-height','list-style','list-style-image', 'list-style-position','list-style-type','margin', 'margin-bottom','margin-left','margin-right', 'margin-top','marker-offset','marks','max-height', 'max-width','min-height','min-width','orphans', 'outline','outline-color','outline-style', 'outline-width','overflow','overflow-x','overflow-y', 'padding','padding-bottom','padding-left', 'padding-right','padding-top','page','page-break-after', 'page-break-before','page-break-inside','pause', 'pause-after','pause-before','pitch','pitch-range', 'play-during','position','quotes','richness', 'right','ruby-align','ruby-overhang','ruby-position', 'scrollbar-3dlight-color','scrollbar-arrow-color', 'scrollbar-base-color','scrollbar-darkshadow-color', 'scrollbar-face-color','scrollbar-highlight-color', 'scrollbar-shadow-color','scrollbar-track-color','size', 'speak','speak-header','speak-numeral', 'speak-punctuation','speech-rate','stress', 'table-layout','text-align','text-autospace', 'text-decoration','text-indent','text-justify', 'text-kashida-space','text-shadow','text-transform', 'text-underline-position','top','unicode-bidi', 'vertical-align','visibility','voice-family', 'volume','white-space','width','widows', 'word-break','word-spacing','writing-mode','z-index' ] } function JSSuggestion(){ this.delim = [ " ",":",";","\n", "\t", "\"",".", "'","{","}", "(", ")" ]; this.statemensts = new Array( 'break', 'case', 'catch', 'continue', 'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with' ); this.futures = new Array( 'abstract', 'boolean', 'byte', 'char', 'class', 'const', 'debugger', 'double', 'enum', 'export', 'extends', 'final', 'float', 'goto', 'implements', 'import', 'int', 'interface', 'long', 'native', 'package', 'private','protected', 'public', 'short', 'static', 'super', 'synchronized', 'throws', 'transient', 'volatile' ); this.ObjNames = new Array( 'Global', 'Object', 'Function','Array', 'String', 'Boolean', 'Number', 'Math', 'Date', 'RegExp', 'Error' ); this.reservedWords = new Array(); this.reservedWords = this.reservedWords.concat( this.statemensts ); this.reservedWords = this.reservedWords.concat( this.ObjNames ); } function PHPSuggestion(){ this.delim = [ " ",":",";","\n", "\t", "\"", "'","{","}", "(", ")", "-", ">", "$" ]; this.keywords1 = new Array( 'xception','php_user_filter','array','as','break', 'case','cfunction','class','const','continue','declare', 'default','die','do','echo','else','elseif','empty', 'enddeclare','endfor','endforeach','endif','endswitch', 'endwhile','eval','exit','extends','for','foreach', 'function','global','if','include','include_once', 'isset','list','old_function','require','require_once', 'return','static','switch','unset','use','var','while', 'try', 'catch', 'clone', 'abstract','protected','implements', 'interface','private', 'throw', 'exception','this','final', 'Exception' ); this.keywords2 = new Array( '__FILE__', '__LINE__', '__FUNCTION__', '__CLASS__', '__METHOD__'); this.funcnames = new Array( 'abs','acos','acosh','addcslashes','addslashes', 'apache_child_terminate', 'apache_lookup_uri','apache_note','apache_setenv', 'array_change_key_case','array_chunk','array_count_values', 'array_diff','array_fill','array_filter','array_flip', 'array_intersect','array_key_exists','array_keys', 'array_map','array_merge','array_merge_recursive', 'array_multisort','array_pad','array_pop','array_push', 'array_rand','array_reduce','array_reverse','array_search', 'array_shift','array_slice','array_splice','array_sum', 'array_unique','array_unshift','array_values','array_walk', 'arsort','asin','asinh','asort','assert','assert_options', 'atan','atan2','atanh','base_convert','base64_decode', 'base64_encode','basename','bin2hex','bindec','call_user_func', 'call_user_func_array','call_user_method', 'call_user_method_array', 'ceil','chdir','checkdate','checkdnsrr','chgrp','chmod', 'chop','chown','chr','chroot','chunk_split','clearstatcache', 'closedir','closelog','compact','connection_aborted', 'connection_status','constant','convert_cyr_string', 'copy','cos','cosh','count','count_chars','crc32', 'crypt','ctype_alnum','ctype_alpha','ctype_cntrl', 'ctype_digit','ctype_graph','ctype_lower','ctype_print', 'ctype_punct','ctype_space','ctype_upper','ctype_xdigit', 'current','date','debug_zval_dump','decbin','dechex', 'decoct','define','define_syslog_variables','deg2rad', 'dir','dirname','disk_free_space','disk_total_space', 'diskfreespace','dl','doubleval','end','ereg','ereg_replace', 'eregi','eregi_replace','error_log','escapeshellarg', 'escapeshellcmd','exec','exp','explode','expm1','extract', 'ezmlm_hashfclose','feof','fflush','fgetc','fgetcsv', 'fgets','fgetss','file','file_exists','fileatime', 'filectime','filegroup','fileinode','filemtime','fileowner', 'fileperms','filesize','filetype','floatval','flock', 'floor','flush','fmod','fopen','fopenstream','fpassthru', 'fputs','fread','fscanf','fseek','fsockopen','fstat', 'ftell','ftok','ftruncate','fwrite','get_browser', 'get_cfg_var','get_current_user','get_html_translation_table', 'get_magic_quotes_gpc','get_magic_quotes_runtime', 'get_meta_tags','getallheaders','getcwd','getdate', 'getenv','gethostbyaddr','gethostbyname','gethostbynamel', 'getimagesize','getlastmod','getmxrr','getmygid', 'getmyinode','getmypid','getmyuid','getprotobyname', 'getprotobynumber','getrandmax','getrusage','getservbyname', 'getservbyport','gettimeofday','gettype','gmdate', 'gmmktime','gmstrftime','header','headers_sent','hebrev', 'hebrevc','hexdec','highlight_file','highlight_string', 'htmlentities','htmlspecialchars','hypot','i18n_convert', 'i18n_discover_encoding','i18n_http_input','i18n_http_output', 'i18n_internal_encoding','i18n_ja_jp_hantozen', 'i18n_mime_header_decode', 'i18n_mime_header_encode','ignore_user_abort','image2wbmp', 'imagealphablending','imagearc','imagechar','imagecharup', 'imagecolorallocate','imagecolorat','imagecolorclosest', 'imagecolorclosestalpha','imagecolorclosesthwb', 'imagecolordeallocate', 'imagecolorexact','imagecolorexactalpha','imagecolorresolve', 'imagecolorresolvealpha','imagecolorset','imagecolorsforindex', 'imagecolorstotal','imagecolortransparent','imagecopy', 'imagecopymerge','imagecopymergegray','imagecopyresampled', 'imagecopyresized','imagecreate','imagecreatefromgd', 'imagecreatefromgd2','imagecreatefromgd2part','imagecreatefromgif', 'imagecreatefromjpeg','imagecreatefrompng','imagecreatefromstring', 'imagecreatefromwbmp','imagecreatefromxpm','imagecreatetruecolor', 'imagedashedline','imagedestroy','imageellipse','imagefill', 'imagefilledarc','imagefilledellipse','imagefilledpolygon', 'imagefilledrectangle','imagefilltoborder','imagefontheight', 'imagefontwidth','imagegammacorrect','imagegd','imagegd2', 'imageinterlace','imagejpeg','imageline','imageloadfont', 'imagepalettecopy','imagepng','imagepolygon','imagerectangle', 'imagesetbrush','imagesetpixel','imagesetstyle','imagesetthickness', 'imagesettile','imagestring','imagestringup','imagesx', 'imagesy','imagetruecolortopalette','imagetypes', 'imagewbmp','implode','import_request_variables','in_array', 'ini_alter','ini_get','ini_get_all','ini_restore', 'ini_set','intval','ip2long','iptcembed','iptcparse', 'is_array','is_bool','is_callable','is_dir','is_double', 'is_executable','is_file','is_finite','is_float', 'is_infinite','is_int','is_integer','is_link','is_long', 'is_nan','is_null','is_numeric','is_object','is_readable', 'is_real','is_resource','is_scalar','is_string','is_uploaded_file', 'is_writable','is_writeable','join','jpeg2wbmp','key', 'key_exists','krsort','ksort','lcg_value','levenshtein', 'link','linkinfo','localeconv','localtime','log', 'log10','log1p','long2ip','lstat','ltrim','magic_quotes_runtime', 'mail','max','mb_convert_encoding','mb_convert_kana', 'mb_convert_variables','mb_decode_mimeheader', 'mb_decode_numericentity', 'mb_detect_encoding','mb_detect_order','mb_encode_mimeheader', 'mb_encode_numericentity','mb_get_info','mb_http_input', 'mb_http_output','mb_internal','_encoding','mb_language', 'mb_output_handler','mb_parse_str','mb_preferred_mime_name', 'mb_send_mail','mb_strcut','mb_strimwidth','mb_strlen', 'mb_strpos','mb_strrpos','mb_strwidth','mb_substitute_character', 'mb_substr','mbstrcut','mbstrlen','mbstrpos','mbstrrpos', 'mbsubstr','md5','md5_file','metaphone','microtime', 'min','mkdir','mktime','move_uploaded_file','mt_getrandmax', 'mt_rand','mt_srand','mysql','mysql_affected_rows', 'mysql_close','mysql_connect','mysql_create_db','mysql_createdb', 'mysql_data_seek','mysql_db_name','mysql_db_query', 'mysql_dbname','mysql_drop_db','mysql_dropdb','mysql_errno', 'mysql_error','mysql_escape_string','mysql_fetch_array', 'mysql_fetch_assoc','mysql_fetch_field','mysql_fetch_lengths', 'mysql_fetch_object','mysql_fetch_row','mysql_field_flags', 'mysql_field_len','mysql_field_name','mysql_field_seek', 'mysql_field_table','mysql_field_type','mysql_fieldflags', 'mysql_fieldlen','mysql_fieldname','mysql_fieldtable', 'mysql_fieldtype','mysql_free_result','mysql_freeresult', 'mysql_get_client_info','mysql_get_host_info','mysql_get_proto_info', 'mysql_get_server_info','mysql_insert_id','mysql_list_dbs', 'mysql_list_fields','mysql_list_tables','mysql_listdbs', 'mysql_listfields','mysql_listtables','mysql_num_fields', 'mysql_num_rows','mysql_numfields','mysql_numrows', 'mysql_pconnect','mysql_query','mysql_result','mysql_select_db', 'mysql_selectdb','mysql_tablename','mysql_unbuffered_query', 'natcasesort','natsort','next','nl_langinfo','nl2br', 'number_format','ob_clean','ob_end_clean','ob_end_flush', 'ob_flush','ob_get_contents','ob_get_length','ob_get_level', 'ob_get_status','ob_implicit_flush','ob_start','octdec', 'opendir','openlog','ord','pack','parse_ini_file', 'parse_str','parse_url','passthru','pathinfo','pclose', 'pfsockopen','php_logo_guid','php_sapi_name','php_uname', 'phpcredits','phpinfo','phpversion','pi','png2wbmp', 'popen','pos','posix_ctermid','posix_errno','posix_get_last_error', 'posix_getcwd','posix_getegid','posix_geteuid','posix_getgid', 'posix_getgrgid','posix_getgrnam','posix_getgroups', 'posix_getlogin','posix_getpgid','posix_getpgrp', 'posix_getpid','posix_getppid','posix_getpwnam','posix_getpwuid', 'posix_getrlimit','posix_getsid','posix_getuid','posix_isatty', 'posix_kill','posix_mkfifo','posix_setegid','posix_seteuid', 'posix_setgid','posix_setpgid','posix_setsid','posix_setuid', 'posix_strerror','posix_times','posix_ttyname','posix_uname', 'pow','preg_grep','preg_match','preg_match_all','preg_quote', 'preg_replace','preg_replace_callback','preg_split', 'prev','print_r','printf','putenv','quoted_printable_decode', 'quotemeta','rad2deg','rand','range','rawurldecode', 'rawurlencode','readdir','readfile','readlink','realpath', 'register_shutdown_function','register_tick_function', 'rename','reset','rewind','rewinddir','rmdir','round', 'rsort','rtrim','serialize','session_cache_expire', 'session_cache_limiter','session_decode','session_destroy', 'session_encode','session_get_cookie_params','session_id', 'session_is_registered','session_module_name','session_name', 'session_register','session_save_path','session_set_cookie_params', 'session_set_save_handler','session_start','session_unregister', 'session_unset','session_write_close','set_file_buffer', 'set_magic_quotes_runtime','set_socket_blocking', 'set_time_limit','setcookie','setlocale','settype', 'shell_exec','show_source','shuffle','similar_text', 'sin','sinh','sizeof','sleep','socket_get_status', 'socket_set_blocking','socket_set_timeout','sort', 'soundex','split','spliti','sprintf','sql_regcase', 'sqrt','srand','sscanf','stat','str_pad','str_repeat', 'str_replace','str_rot13','strchr','strcoll','strcspn', 'strftime','strip_tags','stripcslashes','stripslashes', 'stristr','strnatcasecmp','strnatcmp','strpos','strrchr', 'strrev','strrpos','strspn','strstr','strtok','strtolower', 'strtotime','strtoupper','strtr','strval','substr', 'substr_count','substr_replace','symlink','syslog', 'system','tan','tanh','tempnam','time','tmpfile', 'touch','trim','uasort','ucfirst','ucwords','uksort', 'umask','uniqid','unlink','unpack','unregister_tick_function', 'unserialize','urldecode','urlencode','usleep','usort', 'var_dump','var_export','version_compare','virtual'); this.constants = new Array( '_COOKIE', '_ENV', '_FILES', '_GET', '_POST', '_REQUEST', '_SERVER', '_SESSION', 'ABDAY_1', 'PHP_SELF','argv','argc','GATEWAY_INTERFACE','SERVER_ADDR', 'SERVER_NAME','SERVER_SOFTWARE','REQUEST_METHOD', 'REQUEST_TIME','QUERY_STRING','DOCUMENT_ROOT','HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET','HTTP_ACCEPT_ENCODING','HTTP_ACCEPT_LANGUAGE', 'HTTP_CONNECTION','HTTP_HOST','HTTP_REFERER','HTTP_USER_AGENT', 'HTTPS','REMOTE_ADDR','REMOTE_HOST','REMOTE_PORT', 'SERVER_ADMIN','SERVER_PORT','SERVER_SIGNATURE','PATH_TRANSLATED', 'SCRIPT_FILENAME','PATH_INFO','SCRIPT_NAME','REQUEST_URI', 'PHP_AUTH_DIGEST','PHP_AUTH_USER','PHP_AUTH_PW','AUTH_TYPE', 'ABDAY_2','ABDAY_3', 'ABDAY_4', 'ABDAY_5', 'ABDAY_6', 'ABDAY_7', 'ABMON_1', 'ABMON_10', 'ABMON_11', 'ABMON_12', 'ABMON_2','ABMON_3', 'ABMON_4', 'ABMON_5', 'ABMON_6', 'ABMON_7', 'ABMON_8', 'ABMON_9', 'ALT_DIGITS', 'AM_STR', 'ASSERT_ACTIVE', 'ASSERT_BAIL', 'ASSERT_CALLBACK', 'ASSERT_QUIET_EVAL', 'ASSERT_WARNING','CASE_LOWER','CASE_UPPER','CHAR_MAX', 'CODESET','CONNECTION_NORMAL','CONNECTION_TIMEOUT', 'COUNT_NORMAL','COUNT_RECURSIVE','CREDITS_ALL', 'CREDITS_DOCS','CREDITS_FULLPAGE','CREDITS_GENERAL', 'CREDITS_GROUP','CREDITS_MODULES','CREDITS_QA', 'CREDITS_SAPI','CRNCYSTR','CRYPT_BLOWFISH','CRYPT_EXT_DES', 'CRYPT_MD5','CRYPT_SALT_LENGTH','CRYPT_STD_DES', 'CURRENCY_SYMBOL','D_FMT','D_T_FMT','DAY_1','DAY_2', 'DAY_3','DAY_4','DAY_5','DAY_6','DAY_7','DECIMAL_POINT', 'DEFAULT_INCLUDE_PATH','DIRECTORY_SEPARATOR','E_ALL', 'E_COMPILE_ERROR','E_COMPILE_WARNING','E_CORE_ERROR', 'E_CORE_WARNING','E_ERROR','E_NOTICE','E_PARSE', 'E_USER_ERROR','E_USER_NOTICE','E_USER_WARNING', 'E_WARNING','ENT_COMPAT','ENT_NOQUOTES', 'ENT_QUOTES','ERA','ERA_D_FMT','ERA_D_T_FMT', 'ERA_T_FMT','ERA_YEAR','EXTR_IF_EXISTS','EXTR_OVERWRITE', 'EXTR_PREFIX_ALL','EXTR_PREFIX_IF_EXISTS','EXTR_PREFIX_INVALID', 'EXTR_PREFIX_SAME','EXTR_SKIP','FRAC_DIGITS','GLOBALS', 'GROUPING','HTML_ENTITIES','HTML_SPECIALCHARS', 'INFO_ALL','INFO_CONFIGURATION','INFO_CREDITS', 'INFO_ENVIRONMENT','INFO_GENERAL','INFO_LICENSE','INFO_MODULES', 'INFO_VARIABLES','INI_ALL','INI_PERDIR','INI_SYSTEM', 'INI_USER','INT_CURR_SYMBOL','INT_FRAC_DIGITS','LC_ALL', 'LC_COLLATE','LC_CTYPE','LC_MESSAGES','LC_MONETARY', 'LC_NUMERIC','LC_TIME','LOCK_EX','LOCK_NB','LOCK_SH', 'LOCK_UN','LOG_ALERT','LOG_AUTH','LOG_AUTHPRIV','LOG_CONS', 'LOG_CRIT','LOG_CRON','LOG_DAEMON','LOG_DEBUG','LOG_EMERG', 'LOG_ERR','LOG_INFO','LOG_KERN','LOG_LOCAL0','LOG_LOCAL1', 'LOG_LOCAL2','LOG_LOCAL3','LOG_LOCAL4','LOG_LOCAL5', 'LOG_LOCAL6','LOG_LOCAL7','LOG_LPR','LOG_MAIL','LOG_NDELAY', 'LOG_NEWS','LOG_NOTICE','LOG_NOWAIT','LOG_ODELAY', 'LOG_PERROR','LOG_PID','LOG_SYSLOG','LOG_USER','LOG_UUCP', 'LOG_WARNING','M_1_PI','M_2_PI','M_2_SQRTPI','M_E','M_LN10', 'M_LN2','M_LOG10E','M_LOG2E','M_PI','M_PI_2','M_PI_4', 'M_SQRT1_2','M_SQRT2','MON_1','MON_10','MON_11','MON_12', 'MON_2','MON_3','MON_4','MON_5','MON_6','MON_7','MON_8', 'MON_9','MON_DECIMAL_POINT','MON_GROUPING','MON_THOUSANDS_SEP', 'N_CS_PRECEDES','N_SEP_BY_SPACE','N_SIGN_POSN','NEGATIVE_SIGN', 'NOEXPR','NOSTR','P_CS_PRECEDES','P_SEP_BY_SPACE','P_SIGN_POSN', 'PATHINFO_BASENAME','PATHINFO_DIRNAME','PATHINFO_EXTENSION', 'PEAR_EXTENSION_DIR','PEAR_INSTALL_DIR','PHP_BINDIR', 'PHP_CONFIG_FILE_PATH','PHP_DATADIR','PHP_EXTENSION_DIR', 'PHP_LIBDIR','PHP_LOCALSTATEDIR','PHP_OS','PHP_OUTPUT_HANDLER_CONT', 'PHP_OUTPUT_HANDLER_END','PHP_OUTPUT_HANDLER_START','PHP_SYSCONFDIR', 'PHP_VERSION','PM_STR','POSITIVE_SIGN','RADIXCHAR','SEEK_CUR', 'SEEK_END','SEEK_SET','SORT_ASC','SORT_DESC','SORT_NUMERIC', 'SORT_REGULAR','SORT_STRING','STR_PAD_BOTH','STR_PAD_LEFT', 'STR_PAD_RIGHT','T_FMT','T_FMT_AMPM','THOUSANDS_SEP', 'THOUSEP','YESEXPR','YESSTR'); this.reservedWords = new Array(); this.reservedWords = this.reservedWords.concat( this.keywords1 ); this.reservedWords = this.reservedWords.concat( this.keywords2 ); this.reservedWords = this.reservedWords.concat( this.funcnames ); this.reservedWords = this.reservedWords.concat( this.constants ); } CssSuggestion.prototype = new Suggestion; PHPSuggestion.prototype = new Suggestion; JSSuggestion.prototype = new Suggestion; switch( document.ConfigName ){ case("CSS"): suggestion = new CssSuggestion; break; case("JavaScript"): case("JavaScript for EmEditor"): suggestion = new JSSuggestion; break; case("PHP"): suggestion = new PHPSuggestion; break; default: suggestion = new CssSuggestion; } suggestion.show();