String truncation/summarization Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.

Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so that the length of output equals a given width.

Rules


Input is a string, a width and a sep (separator);
if len(string) &lt;= width: output = string, meaning that the output is the string itself unchanged;
if width &lt;= len(sep): output = sep, meaning that the output is the separator only;
len(output) must be equal to width, with the exception of the previous case;
The excess character in case of uneven number of remaining characters for each half of the string can be placed on the left or right halve;
Standard code-golf challenge with the smallest program to win.


Examples

Format: "string" [length(string)] --&gt; "output" [length(ouput) / width] with sep equal to _(...)_ (_ are whitespaces).

"xtlgxbdwytxcjacu" [16] --&gt; "x (...) " [8 / 8]
"upjptz" [6] --&gt; " (...) " [7 / 3]
"h" [1] --&gt; "h" [1 / 1]
"qsshkvmawcmf" [12] --&gt; " (...) " [7 / 7]
"tvdknroxszhufgck" [16] --&gt; "tv (...) k" [10 / 10]
"ag" [2] --&gt; "ag" [2 / 5]
"vbgdegtgshnzjrudca" [18] --&gt; "vbgd (...) udca" [15 / 15]
"bscwimjjhmgvcwp" [15] --&gt; "bscwimjjhmgvcwp" [15 / 18]
"xwhgbaenornbzwirlp" [18] --&gt; "xwhgbaenornbzwirlp" [18 / 18]
"tbqyrekkzyizc" [13] --&gt; "t (...) " [8 / 8]
"oowdwbeezeh" [11] --&gt; "o (...) h" [9 / 9]
"avlzfzpjazhjc" [13] --&gt; "avlzfzpjazhjc" [13 / 15]
"dngxmebwenfrbidonses" [20] --&gt; "dngxme (...) donses" [19 / 19]
"bqfxyffdemjghipk" [16] --&gt; "bqfxyffdemjghipk" [16 / 16]
"sfwnlkreghzff" [13] --&gt; " (...) " [7 / 5]
"dznlsyaojtferxh" [15] --&gt; "dznlsyaojtferxh" [15 / 17]
"zwkhjdafkzjdgc" [14] --&gt; "zwk (...) dgc" [13 / 13]
"kpzochngmwoulne" [15] --&gt; "kpz (...) lne" [13 / 13]
"vluqvhpcxg" [10] --&gt; "vluqvhpcxg" [10 / 10]
"wuc" [3] --&gt; "wuc" [3 / 8]
Python 2, 93 76 72 bytes



s,w,p=input()
l=len(s)
if w&lt;l:w=max(w-len(p),0);s[-~w/2:l-w/2]=p
print s


Try it online!

Input and output are a list of characters